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
Post a Comment