Mongoose retrieving data without _id field

Another way is to use text argument with prefix - which will exclude this or that field from the result:

Entity.find({ ... }, '-_id field1 field2', function(err, entity) {
    console.log(entity);  // { field1: '...', field2: '...' }
});

Leave a Comment