Monday 29 May 2017

MONGODB Retrieve and Delete ~ GNIITHELP



Retrieve data in MongoDB

Now, if we want to retrieve data against field friends from document with _id xyz123, it can be done with the help of below code snippet:
Retrieve Data in MongoDB

The output produced on console is:
Retrieve Data in MongoDB

Delete data in MongoDB

Now, in our friends field, we have data as “andy”“John” and "Amit". If we want to remove “John” from the list, we can with the help of the below code.
Delete Data in MongoDB

The output of the query is:
Delete Data in MongoDB

“John” is removed from the field friends.

No comments:

Post a Comment