G
G
Gimir2019-06-15 11:03:55
MongoDB
Gimir, 2019-06-15 11:03:55

Can't retrieve specific document from collection in MongoDB in express/node.js?

Good day!
Here is the structure of the collection:

{ 
_id: 5d0276d01c9fa20db57e2fe3,
  name: 'books',
  dictionaries: [] 
}

And here is the code:
var newSet;
  db.get().collection('groups').findOne({_id: ObjectID(dictionary.parId)}, {dictionaries: 1}, (err, doc) => {
    if(err) return console.log(err);
    newSet = doc;
  });

According to the documentation, I should only get the "dictionaries" field, but I get the whole document, why?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question