【问题标题】:updated_at and created_at fields not inserted automatically while inserting into collections using InserGetId function?使用 InserGetId 函数插入集合时未自动插入 updated_at 和 created_at 字段?
【发布时间】:2017-11-16 09:05:10
【问题描述】:

我正在使用 mongoDB,并且在使用 InsertGetId 将数据插入集合时,但 created_at 和 updated_at 字段正在填充 mongo db 集合中。但是对于剩余的集合,我使用 insert 将数据放入集合中。所以,为此我得到了 updated_at 和 created_at 时间戳。为什么? 请解释一下。

【问题讨论】:

  • 寻求调试帮助的问题(“为什么这段代码不起作用?”)必须包括所需的行为、特定的问题或错误以及必要的最短代码 重现它在问题本身。没有明确的问题陈述的问题对其他读者没有用处。见:How to create a Minimal, Complete, and Verifiable example.

标签: mongodb laravel collections


【解决方案1】:

如果我们使用 InsertInsertGetId 函数将数据插入到集合中。而不是我们可以使用 create 函数,因为这个 create 函数会自动为 mongoDB 获取 update_at 和 created_at。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-10-23
    • 1970-01-01
    • 2016-06-13
    • 1970-01-01
    • 2021-03-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多