Created
March 11, 2021 09:41
-
-
Save mlicheng/62e596a16b19bcda7a85a8a63176a5af to your computer and use it in GitHub Desktop.
mongodb find by array element type
This file contains hidden or 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
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