无法将字符串更新为MongoDB中的日期对象4.2
我有一个由日期组成的字符串字段,我试图在在mongodb中更新到日期对象的字符串
db.getCollection('rft').updateMany(
{},[{ "$set": { "createdate": { "$toDate": "$create_date" } }}]
);
获取错误: 错误:无法执行脚本。
错误:更新操作文档必须包含原子操作员 细节: dbcollection.prototype.updatemany@src/mongo/shell/crud_api.js:625:1 @(shell):1:1
有人可以帮助更新记录以随着日期时间获取新字段。
I have a string field which consists of date, I am trying to run following command mentioned in Update string to Date object in mongodb
db.getCollection('rft').updateMany(
{},[{ "$set": { "createdate": { "$toDate": "$create_date" } }}]
);
Getting an error:
Error: Failed to execute script.
Error: the update operation document must contain atomic operators
Details:
DBCollection.prototype.updateMany@src/mongo/shell/crud_api.js:625:1
@(shell):1:1
Can someone please help in updating the records to get new field with date time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的查询似乎可以按预期工作,请检查 playgroud 除非预期有所不同...
Your query seems to work as expected , check playgroud unless something different is expected ...