Answer the question
In order to leave comments, you need to log in
How to make a selection on two fields of a mongodb subdocument?
Hello! I can't figure out why my sample doesn't work correctly.
I am writing this query:
documents
.find(
{ "routes._id": req.session.userId, token: req.session.userGroup, "routes.canSee": 'yes' },
{ document: 0 }
)
[{
...какие то поля обьекта документа
routes: [ { _id: '5a721c536ba3e60ae446d66c',
role: 'Доцент',
author: 'Шестопалов Сергей Викторович',
canSee: 'yes',
status: 'waiting' }]
},
{ _id: '5a747c3d182e5a59e7f329c2', // по этому условию прошло
role: 'Профессор',
author: 'Кимкин Василий Викторович',
canSee: 'no', // а по этому нет, но документ вошел в выборку
status: 'waiting' } ]
}]
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question