i have collection called posts, had "text" , "author" field. later added "date" field later posts.
how can add date field initial posts, not have date/created-at field.
i guess need use following 2 commands, cant figure out how make connection (i.e. loop)?
db.posts.find({"date":{"$exists":false}} objectid(_id).gettimestamp()
db.posts .find({"date":{"$exists":false}) // looking records without `date` field .foreach(function (record) { // iterating through each record record.date = null; // if want define current date use `new date()` db.posts.save(record); // saving updated record });
Comments
Post a Comment