MongoDB:查找具有复合 _id 的文档

标签 mongodb composite-primary-key

我的收藏中有这样一个复合 _id 的文档:

_id:{a:"", b:""}

我想要的是找到只知道字段 a 值的文档。有什么方法可以做到这一点吗?

谢谢!

最佳答案

当然可以

db.whatever.find({"_id.a":"valueOfa"});

还是我没听懂问题?

关于MongoDB:查找具有复合 _id 的文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41449354/

相关文章:

java - mongoDB根据两个条件选择记录

c# - MongoDB 组合键 : InvalidOperationException: {document}. 不支持身份

mysql - Oracle MySQL : Cannot add foreign key constraint

mysql - javax.persistence.EntityExistsException : a different object with the same identifier value was already associated with the session 异常

mongodb - Mongo 3.2 SCRAM-SHA-1 身份验证问题

macos - Mongorestore - 打开的文件太多 - mac os x

c# - "Cannot insert explicit value for identity column in table when IDENTITY_INSERT is set to OFF"带复合键

java - Hibernate注释以映射与复合主键的一对一单向关联

php - PHP 中的 MongoDB - 如何将项目插入集合中的数组?

javascript - 更改 mongo 集合的顺序( Handlebars / meteor )