早上好,我有一个模特的以下藏品
{ "_id" : "ZWx0aWVtcG86NTM0MzU0OmNhdGFsaW5hOTMwOTky", "websiteId" : "eltiempo", "sectionSlug" : "justicia/investigacion", "contentId" : "534354", "reactionId" : "contribute", "createdAt" : ISODate("2020-08-28T14:26:33.791Z"), "userName" : "catalina930992", "test" : "test", "testnew" : "test" }
{ "_id" : "ZWx0aWVtcG86NTM0MzU0OmxpZGVyNzM=", "websiteId" : "eltiempo", "sectionSlug" : "justicia/investigacion", "contentId" : "534354", "reactionId" : "contribute", "createdAt" : ISODate("2020-08-28T14:39:01.893Z"), "userName" : "lider73", "test" : "test", "testnew" : "test" }
{ "_id" : "ZWx0aWVtcG86NTM0MzU0OnJlbmVjYXN0aWxsbzA1MTY=", "websiteId" : "eltiempo", "sectionSlug" : "justicia/investigacion", "contentId" : "534354", "reactionId" : "recommend", "createdAt" : ISODate("2020-08-28T15:47:40.570Z"), "userName" : "renecastillo0516", "test" : "test", "testnew" : "test" }
将数据库插入到与环回api完美配合的数据库中,但是我想通过数组进行更新以插入新字段,我这样做的方式是
var updatecollection = await reacciones.updateMany(
{"contentId": "534354"},
{$set: {
"newfield": 'test',
"publishedNoteAt": 'test'
}},
{ upsert: true }
)
此代码在mongo中有效,但在环回中不起作用
const reacciones = (this.reactionsRepository.dataSource.connector as any).collection("Reactions");
for (var item of elasticrange){
var updatecollection = await reacciones.updateMany(
{"contentId": "534354"},
{$set: {
"newfield": 'test',
"publishedNoteAt": 'test'
}},
{ upsert: true }
)
此代码无效,并且在模型中使用字符串声明了新字段
我想尝试使用带有更新的回送api来做到这一点,但也无法正常工作,如果我做错了任何帮助?
var update = await this.reactionsRepository.updateAll({"websiteId" : "eltiempo", "sectionSlug" : "justicia/investigacion", "contentId" : "534354", "reactionId" : "recommend", "createdAt" : "2020-08-28T16:00:58.650Z", "userName" : "195073" }
,{"contentId" : "534354"});
console.log('update',update)
//appear count 1 but no update nothing
感谢您的帮助