node.js - how to find distinct field of a model upon an and condition in mongoose? -
i looking find list of distinct fields of model satisfies both 2 conditions.
from doc : http://mongoosejs.com/docs/api.html#model_model.distinct
i found can pass array of conditions second parameter in model.distinct()
. array of conditions seems linked via 'or' operation. if 1 condition satisfies field listed.
but want field if both conditions satisfies.
and when use :
model.distinct(field).and(arrayofconditions).exec(callback);
then error :
typeerror: cannot call method 'map' of undefined @ schemaboolean.handlearray (/users/user1/node_modules/mongoose/lib/schema/boolean.js:56:14)
distinct
doesn't return full functioning query
object instead:
model.distinct(field, {$and: arrayofconditions}).exec(callback);
Comments
Post a Comment