Add and Remove Document From Nested Document

Hi,

Following json shows a list and it’s content, I am able to add multiple list to parent document but how do I add and remove content into and from list.List is child document and their are multiple list. So to sum up their is one parent list, which has multiple list and list has content. Below is one such list.

{
    "list": {
      "app_type": "web",
      "content": [
        {
          "app_type": "web",
          "created_on": "2016-05-20 11:06:35",
          "id": "36",
          "latitude": "28.55038400",
          "location_type": null,
          "longitude": "77.25013200",
          "modified_on": "2017-10-07 18:22:23",
          "name": "Oh Calcutta, Nehru New Delhi, Delhi",
          "place_id": "4D5278",
          "status": "1",
          "user_name": "mustanish123"
        },
        {
          "app_type": "web",
          "created_on": "2016-05-24 03:49:03",
          "id": "64",
          "latitude": "27.61418916",
          "location_type": null,
          "longitude": "77.53875732",
          "modified_on": "2017-10-07 18:22:23",
          "name": "Sihana, Sihana, Chhata, Mathura District, Uttar Pradesh",
          "place_id": "OXRYVK",
          "status": "0",
          "user_name": "mustanish123"
        },
        {
          "app_type": "web",
          "created_on": "2016-05-28 05:05:01",
          "id": "129",
          "latitude": "27.15701900",
          "location_type": null,
          "longitude": "77.99160000",
          "modified_on": "2017-10-07 18:22:23",
          "name": "Agra, Uttar Pradesh",
          "place_id": "123ZRR",
          "status": "0",
          "user_name": "mustanish123"
        },
        {
          "app_type": "web",
          "created_on": "2016-05-31 06:59:28",
          "id": "144",
          "latitude": "24.26852200",
          "location_type": null,
          "longitude": "86.64643600",
          "modified_on": "2017-10-07 18:22:23",
          "name": "Madhupur, Jharkhand",
          "place_id": "4AE254",
          "status": "1",
          "user_name": "mustanish123"
        },
        {
          "app_type": "web",
          "created_on": "2016-08-08 11:47:49",
          "id": "7282",
          "latitude": "28.59332900",
          "location_type": null,
          "longitude": "77.25074100",
          "modified_on": "2017-04-10 18:57:12",
          "name": "Humayuns Tomb, Nizamuddin East, New Delhi, Delhi",
          "place_id": "DCE74D",
          "status": "1",
          "user_name": "mustanish123"
        },
        {
          "app_type": "mobile-web",
          "created_on": "2016-10-28 09:24:08",
          "id": "10222",
          "latitude": "23.68276800",
          "location_type": null,
          "longitude": "86.98398100",
          "modified_on": "2017-04-10 18:57:12",
          "name": "Asansol, West Bengalz",
          "place_id": "3LJ9QZ",
          "status": "0",
          "user_name": "mustanish123"
        },
        {
          "app_type": "native",
          "created_on": "2016-11-16 11:42:07",
          "id": "11219",
          "latitude": "28.54951300",
          "location_type": "office",
          "longitude": "77.26780900",
          "modified_on": "2017-09-20 19:01:06",
          "name": "Mapmyindia Head Office New Delhi  Okhla Industrial Estate Phase 3  New Delhi  Delhi",
          "place_id": "MMI000",
          "status": "1",
          "user_name": "mustanish123"
        },
        {
          "app_type": "mobile-web",
          "created_on": "2016-11-23 07:12:40",
          "id": "11431",
          "latitude": "27.17174000",
          "location_type": null,
          "longitude": "78.04208000",
          "modified_on": "2017-04-10 18:57:12",
          "name": "The Great Gate, Forest Colony, Taj Ganj, Agra, Uttar Pradeshz",
          "place_id": "3UVVRD",
          "status": "1",
          "user_name": "mustanish123"
        },
        {
          "app_type": "web",
          "created_on": "2016-12-06 01:06:03",
          "id": "11766",
          "latitude": "18.78151672",
          "location_type": null,
          "longitude": "76.54724121",
          "modified_on": "2017-04-10 18:57:12",
          "name": "Indiranagar, Parli, Bid District, Maharashtra",
          "place_id": "37B3FT",
          "status": "1",
          "user_name": "mustanish123"
        },
        {
          "app_type": "mobile-web",
          "created_on": "2017-02-15 16:46:02",
          "id": "14686",
          "latitude": "28.54913500",
          "location_type": null,
          "longitude": "77.26803800",
          "modified_on": "2017-04-10 18:57:12",
          "name": "Mapmyindia Branch Office New Delhi, Okhla Industrial Estate Phase 3, New Delhi, Delhi",
          "place_id": "LMJAGF",
          "status": "0",
          "user_name": "mustanish123"
        },
        {
          "app_type": "mobile-web",
          "created_on": "2017-02-18 19:54:29",
          "id": "14920",
          "latitude": "22.62898800",
          "location_type": null,
          "longitude": "88.43425500",
          "modified_on": "2017-04-10 18:57:12",
          "name": "Bp Poddar Institute Of Management And Technology, Biman Nagar, Kaikhali, Kolkata, West Bengal",
          "place_id": "4FB448",
          "status": "1",
          "user_name": "mustanish123"
        },
        {
          "app_type": "native",
          "created_on": "2017-09-20 19:02:33",
          "id": "38873",
          "latitude": "28.53640100",
          "location_type": null,
          "longitude": "77.22342200",
          "modified_on": "2017-09-21 10:30:14",
          "name": "Triveni Commercial Complex  Sheikh Sarai Phase 1  New Delhi  Delhi",
          "place_id": "SOSM9C",
          "status": "1",
          "user_name": "mustanish123"
        },
        {
          "app_type": "native",
          "created_on": "2017-09-21 10:30:14",
          "id": "38894",
          "latitude": "24.19160100",
          "location_type": "home",
          "longitude": "86.29272000",
          "modified_on": "2017-09-21 10:30:14",
          "name": "Giridih  Jharkhand",
          "place_id": "FS2SE3",
          "status": "1",
          "user_name": "mustanish123"
        },
        {
          "app_type": "native",
          "created_on": "2017-11-23 16:33:55",
          "id": "45485",
          "latitude": "29.47163600",
          "location_type": null,
          "longitude": "79.14937000",
          "modified_on": "2017-11-23 16:33:55",
          "name": "The Hridayesh Wilderness Resort",
          "place_id": "16MUAF",
          "status": "1",
          "user_name": "mustanish123"
        }
      ],
      "content_count": 14,
      "created_on": "2016-05-10 10:52:28",
      "identifier": "a363d5b8176f2365eb9f12871e12151b",
      "is_public": "0",
      "list_id": "2",
      "list_name": "Favourites",
      "modified_on": "2017-11-12 19:56:31",
      "point": "0",
      "status": 1,
      "user_name": "dceec1f61ed0676bcf7fe7440e618888"
    }
  }

You can use OBJECT constructs, ARRAY constructs, OBJECT functions, ARRAY functions
https://developer.couchbase.com/documentation/server/current/n1ql/n1ql-language-reference/objectfun.html
https://developer.couchbase.com/documentation/server/5.0/n1ql/n1ql-language-reference/arrayfun.html

If you are looking update checkout Update Array of object's when object.name is present, if not present add object to Array

@vsr1 To use array function I need to first get that array from database then use that array in array function.I want to remove this object from list just passing id I mean Is is possible with single query.
suppose this is the object I want to remove or add
{
“app_type”: “mobile-web”,
“created_on”: “2016-10-28 09:24:08”,
“id”: “10222”,
“latitude”: “23.68276800”,
“location_type”: null,
“longitude”: “86.98398100”,
“modified_on”: “2017-04-10 18:57:12”,
“name”: “Asansol, West Bengalz”,
“place_id”: “3LJ9QZ”,
“status”: “0”,
“user_name”: “mustanish123”
}

Hi,

This is the document I have as a list and it has content in it, How do I push and pop content from it.

"lists": 
[
    {
        "app_type": "web",
        "content": [
          {
            "app_type": "web",
            "created_on": "2016-05-20 11:06:35",
            "id": "36",
            "latitude": "28.55038400",
            "location_type": null,
            "longitude": "77.25013200",
            "modified_on": "2017-10-07 18:22:23",
            "name": "Oh Calcutta, Nehru New Delhi, Delhi",
            "place_id": "4D5278",
            "status": "1",
            "user_name": "mustanish123"
          },
          {
            "app_type": "web",
            "created_on": "2016-05-24 03:49:03",
            "id": "64",
            "latitude": "27.61418916",
            "location_type": null,
            "longitude": "77.53875732",
            "modified_on": "2017-10-07 18:22:23",
            "name": "Sihana, Sihana, Chhata, Mathura District, Uttar Pradesh",
            "place_id": "OXRYVK",
            "status": "0",
            "user_name": "mustanish123"
          },
          {
            "app_type": "web",
            "created_on": "2016-05-28 05:05:01",
            "id": "129",
            "latitude": "27.15701900",
            "location_type": null,
            "longitude": "77.99160000",
            "modified_on": "2017-10-07 18:22:23",
            "name": "Agra, Uttar Pradesh",
            "place_id": "123ZRR",
            "status": "0",
            "user_name": "mustanish123"
          },
          {
            "app_type": "web",
            "created_on": "2016-05-31 06:59:28",
            "id": "144",
            "latitude": "24.26852200",
            "location_type": null,
            "longitude": "86.64643600",
            "modified_on": "2017-10-07 18:22:23",
            "name": "Madhupur, Jharkhand",
            "place_id": "4AE254",
            "status": "1",
            "user_name": "mustanish123"
          },
          {
            "app_type": "web",
            "created_on": "2016-08-08 11:47:49",
            "id": "7282",
            "latitude": "28.59332900",
            "location_type": null,
            "longitude": "77.25074100",
            "modified_on": "2017-04-10 18:57:12",
            "name": "Humayuns Tomb, Nizamuddin East, New Delhi, Delhi",
            "place_id": "DCE74D",
            "status": "1",
            "user_name": "mustanish123"
          },
          {
            "app_type": "mobile-web",
            "created_on": "2016-10-28 09:24:08",
            "id": "10222",
            "latitude": "23.68276800",
            "location_type": null,
            "longitude": "86.98398100",
            "modified_on": "2017-04-10 18:57:12",
            "name": "Asansol, West Bengalz",
            "place_id": "3LJ9QZ",
            "status": "0",
            "user_name": "mustanish123"
          },
          {
            "app_type": "native",
            "created_on": "2016-11-16 11:42:07",
            "id": "11219",
            "latitude": "28.54951300",
            "location_type": "office",
            "longitude": "77.26780900",
            "modified_on": "2017-09-20 19:01:06",
            "name": "Mapmyindia Head Office New Delhi  Okhla Industrial Estate Phase 3  New Delhi  Delhi",
            "place_id": "MMI000",
            "status": "1",
            "user_name": "mustanish123"
          },
          {
            "app_type": "mobile-web",
            "created_on": "2016-11-23 07:12:40",
            "id": "11431",
            "latitude": "27.17174000",
            "location_type": null,
            "longitude": "78.04208000",
            "modified_on": "2017-04-10 18:57:12",
            "name": "The Great Gate, Forest Colony, Taj Ganj, Agra, Uttar Pradeshz",
            "place_id": "3UVVRD",
            "status": "1",
            "user_name": "mustanish123"
          },
          {
            "app_type": "web",
            "created_on": "2016-12-06 01:06:03",
            "id": "11766",
            "latitude": "18.78151672",
            "location_type": null,
            "longitude": "76.54724121",
            "modified_on": "2017-04-10 18:57:12",
            "name": "Indiranagar, Parli, Bid District, Maharashtra",
            "place_id": "37B3FT",
            "status": "1",
            "user_name": "mustanish123"
          },
          {
            "app_type": "mobile-web",
            "created_on": "2017-02-15 16:46:02",
            "id": "14686",
            "latitude": "28.54913500",
            "location_type": null,
            "longitude": "77.26803800",
            "modified_on": "2017-04-10 18:57:12",
            "name": "Mapmyindia Branch Office New Delhi, Okhla Industrial Estate Phase 3, New Delhi, Delhi",
            "place_id": "LMJAGF",
            "status": "0",
            "user_name": "mustanish123"
          },
          {
            "app_type": "mobile-web",
            "created_on": "2017-02-18 19:54:29",
            "id": "14920",
            "latitude": "22.62898800",
            "location_type": null,
            "longitude": "88.43425500",
            "modified_on": "2017-04-10 18:57:12",
            "name": "Bp Poddar Institute Of Management And Technology, Biman Nagar, Kaikhali, Kolkata, West Bengal",
            "place_id": "4FB448",
            "status": "1",
            "user_name": "mustanish123"
          },
          {
            "app_type": "native",
            "created_on": "2017-09-20 19:02:33",
            "id": "38873",
            "latitude": "28.53640100",
            "location_type": null,
            "longitude": "77.22342200",
            "modified_on": "2017-09-21 10:30:14",
            "name": "Triveni Commercial Complex  Sheikh Sarai Phase 1  New Delhi  Delhi",
            "place_id": "SOSM9C",
            "status": "1",
            "user_name": "mustanish123"
          },
          {
            "app_type": "native",
            "created_on": "2017-09-21 10:30:14",
            "id": "38894",
            "latitude": "24.19160100",
            "location_type": "home",
            "longitude": "86.29272000",
            "modified_on": "2017-09-21 10:30:14",
            "name": "Giridih  Jharkhand",
            "place_id": "FS2SE3",
            "status": "1",
            "user_name": "mustanish123"
          },
          {
            "app_type": "native",
            "created_on": "2017-11-23 16:33:55",
            "id": "45485",
            "latitude": "29.47163600",
            "location_type": null,
            "longitude": "79.14937000",
            "modified_on": "2017-11-23 16:33:55",
            "name": "The Hridayesh Wilderness Resort",
            "place_id": "16MUAF",
            "status": "1",
            "user_name": "mustanish123"
          }
        ],
        "content_count": 14,
        "created_on": "2016-05-10 10:52:28",
        "identifier": "a363d5b8176f2365eb9f12871e12151b",
        "is_public": "0",
        "list_id": "2",
        "list_name": "Favourites",
        "modified_on": "2017-11-12 19:56:31",
        "point": "0",
        "status": 1,
        "user_name": "dceec1f61ed0676bcf7fe7440e618888"
    },
]

I can append list to list array using array_append or array_prepend but how do I push and pop contents from contents key present.Preformatted text

Not sure what is your question. Are u UPDATING document? Do you want select?
Please post expected output what is criteria that output you are expecting.

@vsr1 I have this document for every user when he sign up

{
  "added": [],
  "comments": [],
  "contribution": [],
  "edited": [],
  "flags": [],
  "followers": [],
  "followings": [],
  "likes": [],
  "lists": [],
  "pins": [],
  "shares": []
} 

As you can see this is basically an array of objects. So if someone adds a list it get updated in his list key.Which I have posted above.I just want to add content if add is performed and delete if delete is performed( based on ID).I can add multiple list to list array but inside list their is a content key which is also an array of its content I want to add content to that array and delete content from that array.Hope I made myself clear.

You can use UPDATE statement to set new values or remove values at any levels. https://developer.couchbase.com/documentation/server/5.0/n1ql/n1ql-language-reference/update.html

Few examples.

Changes status 2 for given list_id and id inside content

UPDATE default  AS d  SET c.status =  "2"
              FOR c IN l.content FOR l IN d.lists WHEN l.list_id = "2" AND c.id = "45485" END;

Removes status for given list_id and id inside content

UPDATE default  AS d  UNSET c.status
              FOR c IN l.content FOR l IN d.lists WHEN l.list_id = "2" AND c.id = "45485" END;

Adds comments for given list_id and id inside content

UPDATE default  AS d  SET c.comments = "Test"
              FOR c IN l.content FOR l IN d.lists WHEN l.list_id = "2" AND c.id = "45485" END;

Removes c.id="45485" form array

UPDATE default  AS d  SET c.content = ARRAY c FOR c IN l.content WHEN c.id != "45485" END
               FOR l IN d.lists WHEN l.list_id = "2" END;

The above examples shows how to modify the documents as UPDATE has condition to avoid unnessary work.
You would like to add the WHERE clause  like below

UPDATE default  AS d  SET l.content = ARRAY c FOR c IN l.content WHEN c.id != "45485" END
               FOR l IN d.lists WHEN l.list_id = "2" END
WHERE ANY l IN d.lists SATISFIES (ANY c IN l.content SATISFIES c.id == "45485" END) END;

@vsr1 As you can see I have nested subdocument for lists array. I can do one level update using update link which you provided but what about multi level sub document.As you can see lists itself is an array which has multiple list. I can add and remove list from lists array using UPDATE function but how do I add entry and remove entry from content key present inside individual list.

Examples above has info that can be expanded any levels

Hi,

All above queries are working as expected apart from the one which can add content or remove content from list.Any help.

@vsr1

Hi,

Following is the actual document I have in my bucket for a user

[
  {
    "activity": {
      "added": [],
      "comments": [],
      "contribution": [],
      "edited": [],
      "flags": [],
      "followers": [],
      "followings": [],
      "likes": [],
      "lists": [
        {
          "app_type": "web",
          "content": [
            {
              "app_type": "web",
              "created_on": "2016-05-20 11:06:35",
              "id": "36",
              "latitude": "28.55038400",
              "location_type": null,
              "longitude": "77.25013200",
              "modified_on": "2017-10-07 18:22:23",
              "name": "Oh Calcutta, Nehru New Delhi, Delhi",
              "place_id": "4D5278",
              "status": "1",
              "user_name": "mustanish123"
            },
            {
              "app_type": "web",
              "created_on": "2016-05-24 03:49:03",
              "id": "64",
              "latitude": "27.61418916",
              "location_type": null,
              "longitude": "77.53875732",
              "modified_on": "2017-10-07 18:22:23",
              "name": "Sihana, Sihana, Chhata, Mathura District, Uttar Pradesh",
              "place_id": "OXRYVK",
              "status": "0",
              "user_name": "mustanish123"
            },
            {
              "app_type": "web",
              "created_on": "2016-05-28 05:05:01",
              "id": "129",
              "latitude": "27.15701900",
              "location_type": null,
              "longitude": "77.99160000",
              "modified_on": "2017-10-07 18:22:23",
              "name": "Agra, Uttar Pradesh",
              "place_id": "123ZRR",
              "status": "0",
              "user_name": "mustanish123"
            },
            {
              "app_type": "web",
              "created_on": "2016-05-31 06:59:28",
              "id": "144",
              "latitude": "24.26852200",
              "location_type": null,
              "longitude": "86.64643600",
              "modified_on": "2017-10-07 18:22:23",
              "name": "Madhupur, Jharkhand",
              "place_id": "4AE254",
              "status": "1",
              "user_name": "mustanish123"
            },
            {
              "app_type": "web",
              "created_on": "2016-08-08 11:47:49",
              "id": "7282",
              "latitude": "28.59332900",
              "location_type": null,
              "longitude": "77.25074100",
              "modified_on": "2017-04-10 18:57:12",
              "name": "Humayuns Tomb, Nizamuddin East, New Delhi, Delhi",
              "place_id": "DCE74D",
              "status": "1",
              "user_name": "mustanish123"
            },
            {
              "app_type": "mobile-web",
              "created_on": "2016-10-28 09:24:08",
              "id": "10222",
              "latitude": "23.68276800",
              "location_type": null,
              "longitude": "86.98398100",
              "modified_on": "2017-04-10 18:57:12",
              "name": "Asansol, West Bengalz",
              "place_id": "3LJ9QZ",
              "status": "0",
              "user_name": "mustanish123"
            },
            {
              "app_type": "native",
              "created_on": "2016-11-16 11:42:07",
              "id": "11219",
              "latitude": "28.54951300",
              "location_type": "office",
              "longitude": "77.26780900",
              "modified_on": "2017-09-20 19:01:06",
              "name": "Mapmyindia Head Office New Delhi  Okhla Industrial Estate Phase 3  New Delhi  Delhi",
              "place_id": "MMI000",
              "status": "1",
              "user_name": "mustanish123"
            },
            {
              "app_type": "mobile-web",
              "created_on": "2016-11-23 07:12:40",
              "id": "11431",
              "latitude": "27.17174000",
              "location_type": null,
              "longitude": "78.04208000",
              "modified_on": "2017-04-10 18:57:12",
              "name": "The Great Gate, Forest Colony, Taj Ganj, Agra, Uttar Pradeshz",
              "place_id": "3UVVRD",
              "status": "1",
              "user_name": "mustanish123"
            },
            {
              "app_type": "web",
              "created_on": "2016-12-06 01:06:03",
              "id": "11766",
              "latitude": "18.78151672",
              "location_type": null,
              "longitude": "76.54724121",
              "modified_on": "2017-04-10 18:57:12",
              "name": "Indiranagar, Parli, Bid District, Maharashtra",
              "place_id": "37B3FT",
              "status": "1",
              "user_name": "mustanish123"
            },
            {
              "app_type": "mobile-web",
              "created_on": "2017-02-15 16:46:02",
              "id": "14686",
              "latitude": "28.54913500",
              "location_type": null,
              "longitude": "77.26803800",
              "modified_on": "2017-04-10 18:57:12",
              "name": "Mapmyindia Branch Office New Delhi, Okhla Industrial Estate Phase 3, New Delhi, Delhi",
              "place_id": "LMJAGF",
              "status": "0",
              "user_name": "mustanish123"
            },
            {
              "app_type": "mobile-web",
              "created_on": "2017-02-18 19:54:29",
              "id": "14920",
              "latitude": "22.62898800",
              "location_type": null,
              "longitude": "88.43425500",
              "modified_on": "2017-04-10 18:57:12",
              "name": "Bp Poddar Institute Of Management And Technology, Biman Nagar, Kaikhali, Kolkata, West Bengal",
              "place_id": "4FB448",
              "status": "1",
              "user_name": "mustanish123"
            },
            {
              "app_type": "native",
              "created_on": "2017-09-20 19:02:33",
              "id": "38873",
              "latitude": "28.53640100",
              "location_type": null,
              "longitude": "77.22342200",
              "modified_on": "2017-09-21 10:30:14",
              "name": "Triveni Commercial Complex  Sheikh Sarai Phase 1  New Delhi  Delhi",
              "place_id": "SOSM9C",
              "status": "1",
              "user_name": "mustanish123"
            },
            {
              "app_type": "native",
              "created_on": "2017-09-21 10:30:14",
              "id": "38894",
              "latitude": "24.19160100",
              "location_type": "home",
              "longitude": "86.29272000",
              "modified_on": "2017-09-21 10:30:14",
              "name": "Giridih  Jharkhand",
              "place_id": "FS2SE3",
              "status": "1",
              "user_name": "mustanish123"
            },
            {
              "app_type": "native",
              "created_on": "2017-11-23 16:33:55",
              "id": "45485",
              "latitude": "29.47163600",
              "location_type": null,
              "longitude": "79.14937000",
              "modified_on": "2017-11-23 16:33:55",
              "name": "The Hridayesh Wilderness Resort",
              "place_id": "16MUAF",
              "status": "1",
              "user_name": "mustanish123"
            }
          ],
          "content_count": 14,
          "created_on": "2016-05-10 10:52:28",
          "identifier": "a363d5b8176f2365eb9f12871e12151b",
          "is_public": "0",
          "list_id": "2",
          "list_name": "Favourites",
          "modified_on": "2017-11-12 19:56:31",
          "point": "0",
          "status": 1,
          "user_name": "dceec1f61ed0676bcf7fe7440e618888"
        },
        {
          "app_type": "native",
          "content": [
            {
              "app_type": "web",
              "created_on": "2016-09-09 05:19:01",
              "id": "8822",
              "latitude": "13.76339578",
              "location_type": null,
              "longitude": "75.15747070",
              "modified_on": "2017-04-10 18:57:12",
              "name": "Nekragodu, Tirthahalli, Shimoga District, Karnataka",
              "place_id": "TAE2E6",
              "status": "1",
              "user_name": "mustanish123"
            },
            {
              "app_type": "web",
              "created_on": "2017-03-07 14:49:13",
              "id": "16498",
              "latitude": "28.54951300",
              "location_type": null,
              "longitude": "77.26780900",
              "modified_on": "2017-04-10 18:57:12",
              "name": "Mapmyindia Head Office New Delhi, Okhla Industrial Estate Phase 3, New Delhi, Delhi",
              "place_id": "MMI000",
              "status": "1",
              "user_name": "mustanish123"
            }
          ],
          "content_count": 2,
          "created_on": "2016-09-09 05:19:01",
          "identifier": "882491655016be9f53fbc4d91431dae8",
          "is_public": "1",
          "list_id": "194",
          "list_name": "TL 3",
          "modified_on": "2017-11-16 21:30:09",
          "point": "0",
          "status": 1,
          "user_name": "mustanish123"
        },
        {
          "app_type": "native",
          "content": [
            {
              "app_type": "web",
              "created_on": "2016-09-09 05:19:37",
              "id": "8824",
              "latitude": "18.78151672",
              "location_type": null,
              "longitude": "76.54724121",
              "modified_on": "2017-04-10 18:57:12",
              "name": "Indiranagar, Parli, Bid District, Maharashtra",
              "place_id": "37B3FT",
              "status": "1",
              "user_name": "mustanish123"
            },
            {
              "app_type": "web",
              "created_on": "2017-03-07 14:47:57",
              "id": "16497",
              "latitude": "28.54951300",
              "location_type": null,
              "longitude": "77.26780900",
              "modified_on": "2017-04-10 18:57:12",
              "name": "Mapmyindia Head Office New Delhi, Okhla Industrial Estate Phase 3, New Delhi, Delhi",
              "place_id": "MMI000",
              "status": "1",
              "user_name": "mustanish123"
            }
          ],
          "content_count": 2,
          "created_on": "2016-09-09 05:19:37",
          "identifier": "b630a1782ec2dc784711af465b8cbdbd",
          "is_public": "1",
          "list_id": "196",
          "list_name": "TL 55",
          "modified_on": "2017-11-16 21:30:12",
          "point": "0",
          "status": 1,
          "user_name": "mustanish123"
        },
        {
          "app_type": "native",
          "content": [],
          "content_count": 0,
          "created_on": "2017-09-20 19:06:43",
          "identifier": "d48c824e3226f5a10e247d304989fb54",
          "is_public": "1",
          "list_id": "704",
          "list_name": "Testing New",
          "modified_on": "2017-11-16 21:30:13",
          "point": "0",
          "status": 1,
          "user_name": "mustanish123"
        },
        {
          "app_type": "native",
          "content": [
            {
              "app_type": "native",
              "created_on": "2017-11-16 12:22:13",
              "id": "43539",
              "latitude": "23.25113200",
              "location_type": null,
              "longitude": "87.86796300",
              "modified_on": "2017-11-16 12:22:13",
              "name": "Burdwan, West Bengal",
              "place_id": "3LFXBV",
              "status": "1",
              "user_name": "mustanish123"
            },
            {
              "app_type": "native",
              "created_on": "2017-11-23 16:34:05",
              "id": "45486",
              "latitude": "29.47163600",
              "location_type": null,
              "longitude": "79.14937000",
              "modified_on": "2017-11-23 16:34:05",
              "name": "The Hridayesh Wilderness Resort",
              "place_id": "16MUAF",
              "status": "1",
              "user_name": "mustanish123"
            }
          ],
          "content_count": 2,
          "created_on": "2017-11-16 12:22:04",
          "identifier": "a0073ba1da5dc90baebb12b3df6f5303",
          "is_public": "1",
          "list_id": "780",
          "list_name": "Tl99",
          "modified_on": "2017-11-16 21:30:14",
          "point": "0",
          "status": 1,
          "user_name": "mustanish123"
        }
      ],
      "pins": [],
      "shares": []
    }
  }
] 

All above queries are working fine on this document except the one needed to remove or add from list content key.

I ran this query
UPDATE activity d USE KEYS “mustanish123” SET c.content = ( ARRAY c FOR c IN l.content WHEN c.id != “45485” END )
FOR l IN d.lists WHEN l.list_id = “2” END

But the document is still their for list_id 2, I mean It should work am I doing something wrong here

It needs to be SET l.content

UPDATE activity d USE KEYS “mustanish123” SET l.content = ( ARRAY c FOR c IN l.content WHEN c.id != “45485” END )
FOR l IN d.lists WHEN l.list_id = “2” END