O
O
olezhenka2017-05-07 18:50:19
JavaScript
olezhenka, 2017-05-07 18:50:19

How to return from the database of users where a certain field is filled in mongoose?

i did like this, but it returns everyone where the timer field is even empty
7d3e6ee691654360b23639add349197c.PNG

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
dummyman, 2017-05-07
@dummyman

mongoosejs.com/docs/api.html#query_Query-exists
Isn't it?

// { name: { $exists: true }}
Thing.where('name').exists()
Thing.where('name').exists(true)
Thing.find().exists('name')

// { name: { $exists: false }}
Thing.where('name').exists(false);
Thing.find().exists('name', false);

S
SergeyBugai, 2017-05-09
@SergeyBugai

If I'm not mistaken something like this

comunicate.find({
    timer: {
        $exists: true
    }
}, callback)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question