Answer the question
In order to leave comments, you need to log in
How to return field content with mongoose?
I have a mongo schema that looks like this:
//Main object
{
// в нем поля
user: "пум-пум-пум"
password:"абра-казябра"
tasks: [
{
name: ''пум-пум-пум",
startTime: "тут дата",
},
{
name: ''пум-пум-пум",
startTime: "тут дата",
},
{
name: ''пум-пум-пум",
startTime: "тут дата",
},
]
}
User.findOne( {"tasks.startTime": toTimeZone( Date.now(),'Europe/Berlin').toString()}, (err ,user) => {
})
Answer the question
In order to leave comments, you need to log in
Can be done through Aggregation
let pipeline = [
{
$project: {
tasks: {
$filter: {
input: "$tasks",
as: "task",
cond: {$eq:["$$task.startTime", toTimeZone( Date.now(), 'Europe/Berlin').toString()]}
}
}
}
}
]
db.user.aggregate(pipeline);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question