node.js - Mongoose use array in find().where() -


i have array of strings want use parameter finding documents in mongodb.

basically want is

// using query builder person.   find().   where('name.last').equals('ghost' || 'etc' || 'etc').... 

but instead of using bunch of or statements, want pass array of strings.

is possible?

just use .in method, taking $in operator in play:

person.   find().   where('name.last').in(['ghost', 'foo', 'bar']) 

quoting the mongodb docs:

the $in operator selects documents value of field equals value in specified array.


Comments

Popular posts from this blog

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

html - Outlook 2010 Anchor (url/address/link) -

android - How to create dynamically Fragment pager adapter -