Remove a child object in Fauna DB

I need to remove a child object in FQL. Let me demonstrate with the following example:

{
    "1": {
        "name": "test"
    },
    "2": {
        "name": "test2"
    }
}

And I want this JSON to look like this:

{
    "1": {
        "name": "test"
    }
}

Is there an FQL function that could help me?

Answer

When you set a key’s value to null in Fauna, it is removed from the object. In your example, assuming ref is a valid Reference:

Update(ref, { "2": null })

will remove the key "2" and its associated value from the object, leaving you with:

{ "1": { "name": "test" } }
Source: stackoverflow
The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .