Z
Z
zugzug2014-03-12 19:31:35
Node.js
zugzug, 2014-03-12 19:31:35

How to perform OR predicate in query in ODM mongoose.js?

Hello. Studied the query API (find, query, findOne) in the mongoose module provided for Node.js. And I didn’t understand if there is support for the OR predicate in the query, and how is it correctly implemented? Thanks for the clarification and good examples.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Kirill Chernyshov, 2014-03-12
@zugzug

Mongoose API Docs
like this -
or so -

Model
.find({})
.where('name').in(['one', 'another'])
.exec(function(err, result){})

The first option is more like requests in Mongo, the second one is more canonical for Mongoose.

Z
zxmd, 2014-03-12
@zxmd

Studied the query API (find, query, findOne) in the mongoose module provided for Node.js

Crap. The whole problem is that people teach realization and not the very root of evil. Everything is in the documentation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question