node.js - MongoDB find by date in Array -


schema:

var users = mongoose.schema({name: string, usersearchcontractors: [usersearchcontractors]}   var usersearchcontractors = new mongoose.schema({     type:{ type:string,index:  true },     area: { type:string,index:  true },     createdate: { type: date, default: date.now() }     }); 

query:

db.users.find( { usersearchcontractors: { $elemmatch: { createdate: { "$lt": new date()} } } } ) 

what i'm doing wrong users usersearchcontractors.createdate ?

no results

thank,

ron

no need use $elemmatch query.

db.users.find( { 'usersearchcontractors.createdate': { "$lt": new date() } } ) 

Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -