Skip to content

Instantly share code, notes, and snippets.

@detj
Last active December 20, 2015 14:49
Show Gist options
  • Save detj/6149339 to your computer and use it in GitHub Desktop.
Save detj/6149339 to your computer and use it in GitHub Desktop.
MongoDB fascinating queries
/*
* Querying inside an array
*
* {
* "contents": [
* "url": ""
* ]
* }
*/
db.collection.find({"contents": {"$elemMatch": {"url": ""}}})
/*
* Remove an element inside an array based on conditions
*/
db.lectures.update({"contents": {"$elemMatch": {"url": ""}}}, {"$pull": {"contents": { "url": ""}}})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment