Skip to content

Instantly share code, notes, and snippets.

@mlicheng

mlicheng/mongodb

Created Mar 11, 2021
Embed
What would you like to do?
mongodb find by array element type
db.getCollection("collection_name").find({
"filed_name": {
$elemMatch: {
$ne: null,
$type: "string" // object, objectId ...
}
}
}, {
"filed_name": 1
})
// type refer to https://docs.mongodb.com/manual/reference/operator/query/type/index.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment