Created
April 20, 2015 12:28
-
-
Save 409H/0fcecec1336cc738ce85 to your computer and use it in GitHub Desktop.
Find all _id where attribute is object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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