开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜