Created
September 15, 2021 10:00
-
-
Save tutumagi/bdd3f57ccafaba2ca7ccd1c871913f81 to your computer and use it in GitHub Desktop.
mongo shell #mongo
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
// 某个集合中的数组类型的字段至少有一个项目 | |
db.getCollection('tbl_land').find({ | |
"$someArray.0": { | |
"$exists": true, | |
} | |
}) |
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
// 查询某个字段至少有一个 key 的所有结果 | |
db.getCollection('tbl_land').find({ | |
"$expr": { | |
"$gt": [ { "$size": { "$objectToArray": "$ownEntities" } }, 0] | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment