更新MongoDB中的日期字段

发布于 2025-02-13 09:07:21 字数 567 浏览 1 评论 0原文

我在名为“评论”的集合中有以下文档。我想更新过去的到期日期。减1天

{
    "_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"
}

有人可以帮我吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

七禾 2025-02-20 09:07:21
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);
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);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文