简体   繁体   中英

Update date field in mongodb

I have the below document in a collection named "review". I want to update the expiry date in the past. Minus 1 day

{
    "_id" : ObjectId("62bd783086e0ee2176477b93"),
    "expiry" : ISODate("2022-09-28T10:17:20.455Z"),
    "rating" : 5,
    "category" : "Orange Pumpkin Namkeen",
    "merchantId" : "220606131134369EZ0045009",
    "customerName" : "The Man with the Yellow Hat",
    "customerId" : "220606142940700EZ0043018",
    "status" : "SUBMITTED",
    "createdTime" : ISODate("2022-06-30T10:17:20.456Z"),
    "modifiedTime" : ISODate("2022-06-30T10:20:51.955Z"),
    "modifiedBy" : "ezestore"
}

Can someone help me out?

db.test.insert({"Time" : new ISODate("2012-01-10") });


db.test.update({ criteria }, { newObj }, upsert, multi);
For example, to update all objects, consider

db.test.update( {}, { $set : { "time" : new ISODate("2012-01-11T03:34:54Z") } }, true, true);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM