MongoDB Database, equivalent for SELECT column1, column2 FROM tbl
问题 From my MongoDB I want the equivalent for SELECT column1, column2 FROM tbl With this code I get all the 'rows' but also all the 'columns' DBCollection collection = database.getCollection("names"); DBCursor cursor = collection.find(); I for example would like all the 'rows' but only the 'columns': id, name, age How would I do this? Thanks for any help!! 回答1: db.collection.find({}, {_id: 1, name: 1, age: 1}) The first argument to find (the predicate) is your selection criteria, e.g. db