A
A
askold20132018-03-04 19:56:25
MongoDB
askold2013, 2018-03-04 19:56:25

How to make a selection OR on nested fields of a mongo document?

Hello!
I can't figure out how to write the following sample correctly. You need to find a document either by one nested field, or by the second. In my case, the first condition works - search by login. And by mail - no:

Groups.findOne({ $or: [ { 'users.login': req.body.userLogin }, { 'users.email': req.body.userLogin }]}, (err, group) => {
       ....

What is the trouble, tell me?

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