简体   繁体   中英

Does mongodb's find() return objects missing a field from the specified projection?

If I have a mongodb containing this:

{ _id:ObjectId(0), name:"foo", hits:5 }

Will it get returned by this query:

find({name:"foo"}, {hits:1, flow:1})

If so, what will the returned object look like?

Yes it will, and it will look like this:

{ "_id": ObjectId("000000000000000000000000"), "hits": 5 }

name is omitted because it's not included in the projection, but _id is included by default.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM