These are chat archives for Automattic/mongoose

28th
Dec 2016
Bharat
@BharatKalluri
Dec 28 2016 07:49
Hi , How does find and update work?
let us say I have an object as such
{
    "_id" : ObjectId("586358f9e2ce6f42cfc024d7"),
    "gid" : "10",
    "entries" : [ 
        {
            "date" : 20161228,
            "_id" : ObjectId("586358f9e2ce6f42cfc024d8"),
            "entry" : [ 
                "fwaf", 
                "afwaaf", 
            ]
        }
    ],
    "__v" : 0
}
and this query returns nothing
Entry.findOneAndUpdate({'entries.date':20161228},{'entry':['inputis','a']},{upsert:true},function(err,data){
              if (err) console.error(err)
              console.log(data);
              return res.json(data)
            })