Skip to content

Instantly share code, notes, and snippets.

@409H
Created April 20, 2015 12:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 409H/0fcecec1336cc738ce85 to your computer and use it in GitHub Desktop.
Save 409H/0fcecec1336cc738ce85 to your computer and use it in GitHub Desktop.
Find all _id where attribute is object
//http://stackoverflow.com/questions/29747782/in-mongodb-how-to-find-documents-where-property-is-object-but-not-array
//Find all entries where gyms attribute is an object
var arr = [];
db.test.find().forEach(
function isObj(doc) {
if( typeof doc.gyms === 'object') {
arr.push(doc._id);
}
}
}
print( arr.join("\r\n") );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment