return only a single property “_id”

The second parameter of find lets you select fields. So you can use this (note that the _id field is always selected anyway):

db.mycollection.find({}, {"user_id": 1, "total": 1});

You can also exclude certain fields, so this would be equivalent:

db.mycollection.find({}, {"items": 0});

You can exclude _id field by doing:

db.mycollection.find({}, {"user_id": 1, "_id": 0});

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)