开发者

In Mongo, how do I find all the documents, but display only their titles?

开发者 https://www.devze.com 2023-02-12 15:29 出处:网络
There\'s a [\'title\'] attribute inside each document. How can I do a .find, but only display the title?开发者_StackOverflowYou can retrieve a subset of fields within the documents as follows:

There's a ['title'] attribute inside each document. How can I do a .find, but only display the title?开发者_StackOverflow


You can retrieve a subset of fields within the documents as follows:

e.g. looking retrieving only the title field for books with a given ISBN:

db.Books.find({ISBN : "1234567890" }, { title : 1 } );

You can also do field negation, i.e. return all fields EXCEPT the ones you specify. There's a good reference on this on MongoDB.org


you can find that info at http://www.mongodb.org/display/DOCS/Retrieving+a+Subset+of+Fields

0

精彩评论

暂无评论...
验证码 换一张
取 消