gpt4 book ai didi

javascript - 蒙哥错误: Field name duplication not allowed with modifiers

转载 作者:行者123 更新时间:2023-11-30 17:30:42 25 4
gpt4 key购买 nike

注意:据我所知,我不是在做推弹式的事情。

我有这个第一次工作正常,但如果客户端两次调用此方法而没有在两次调用之间刷新页面,我将在标题中得到错误。

scenarios.findOne({'_id':partialUpdate._id},function(err,back){

if(back){
for(var p in partialUpdate){
if(partialUpdate.hasOwnProperty(p)){
back[p] = partialUpdate[p];
}
}
back.save(function(err,product,numberAffected){...

刷新页面以阻止此错误发生的原因是什么?我如何知道我正在复制哪个字段名称,以便我可以停止此错误?

这是服务器输出的副本,其中包含第一组和第二组发送数据 (partialData)、它合并的服务器数据 (back),以及保存的数据(product)和错误信息

http://pastebin.com/izbkZV1h

第一组发送对象:

{ sortOrder: 0,
title: 'sdfsdf',
description: '',
contentType: 'false',
_id: '534ec5c98c4bf1be305fee1c',
__v: 8,
groupSharing: [],
sharingWith: [],
isPublic: false,
content: false,
attributes: [],
metrics:
[ { type: 'viewCount',
value: '1',
metric: 'Viewed',
_id: '534ec5c98c4bf1be305fee1e',
createDate: '2014-04-16T18:02:49.454Z' },
{ type: 'playCount',
value: '1',
metric: 'Played',
_id: '534ec5c98c4bf1be305fee1d',
createDate: '2014-04-16T18:02:49.453Z' } ],
bundleId: [],
video:
[ { videoLocation: 'rtmp://xxxxxxxxxxxxxxxxxxx.cloudfront.net/cfx/st/vid_51323386'
,
thumbnailLocation: 'https://xxxxxxxxxxxxxxxxxxx.cloudfront.net/thumb_51323386.
png',
_id: '534ec5c98c4bf1be305fee20',
createDate: '2014-04-16T18:02:49.457Z',
format: 'FLV' } ],
display: true,
active: true,
createDate: '2014-04-16T18:02:49.000Z',
revision: 1,
scripts:
[ { _id: '534ec5c98c4bf1be305fee1f',
display: true,
active: true,
createDate: '2014-04-16T18:02:49.454Z',
keyPoints: [],
body: [Object],
subject: [] } ],
presentation:
[ { pageLocation: null,
_id: '534ec5c98c4bf1be305fee21',
display: true,
active: true,
syncManifest: [],
pageNumber: [Object] } ],
subcategoryId: [ '53236dff2ab8b9182716f34d' ],
categoryId: [ '532369bb2ab8b9182716f33d' ],
authorId: [ '532c9a146ce0682319cebbf9' ] }

它应该覆盖的服务器上的对象:

 { sortOrder: 0,
title: 'sdfsdf',
description: '',
contentType: 'false',
_id: 534ec5c98c4bf1be305fee1c,
__v: 8,
groupSharing: [],
sharingWith: [],
isPublic: false,
content: false,
attributes: [],
metrics:
[ { type: 'viewCount',
value: '1',
metric: 'Viewed',
_id: 534ec5c98c4bf1be305fee1e,
createDate: Wed Apr 16 2014 12:02:49 GMT-0600 (Mountain Daylight Time) },

{ type: 'playCount',
value: '1',
metric: 'Played',
_id: 534ec5c98c4bf1be305fee1d,
createDate: Wed Apr 16 2014 12:02:49 GMT-0600 (Mountain Daylight Time) }
],
bundleId: [],
video:
[ { videoLocation: 'rtmp://xxxxxxxxxxxxxxxxxxx.cloudfront.net/cfx/st/vid_51323386'
,
thumbnailLocation: 'https://xxxxxxxxxxxxxxxxxxxxcloudfront.net/thumb_51323386.
png',
_id: 534ec5c98c4bf1be305fee20,
createDate: Wed Apr 16 2014 12:02:49 GMT-0600 (Mountain Daylight Time),
format: 'FLV' } ],
display: true,
active: true,
createDate: Wed Apr 16 2014 12:02:49 GMT-0600 (Mountain Daylight Time),
revision: 1,
scripts:
[ { _id: 534ec5c98c4bf1be305fee1f,
display: true,
active: true,
createDate: Wed Apr 16 2014 12:02:49 GMT-0600 (Mountain Daylight Time),
keyPoints: [],
body: [Object],
subject: [] } ],
presentation:
[ { pageLocation: null,
_id: 534ec5c98c4bf1be305fee21,
display: true,
active: true,
syncManifest: [],
pageNumber: [Object] } ],
subcategoryId: [ 53236d392ab8b9182716f341 ],
categoryId: [ 532368bc2ab8b9182716f339 ],
authorId: [ 532c9a146ce0682319cebbf9 ] }

结果对象:

    { sortOrder: 0,
title: 'sdfsdf',
description: '',
contentType: 'false',
_id: 534ec5c98c4bf1be305fee1c,
__v: 9,
groupSharing: [],
sharingWith: [],
isPublic: false,
content: false,
attributes: [],
metrics:
[ { type: 'viewCount',
value: '1',
metric: 'Viewed',
_id: 534ec5c98c4bf1be305fee1e,
createDate: Wed Apr 16 2014 12:02:49 GMT-0600 (Mountain Daylight Time) },

{ type: 'playCount',
value: '1',
metric: 'Played',
_id: 534ec5c98c4bf1be305fee1d,
createDate: Wed Apr 16 2014 12:02:49 GMT-0600 (Mountain Daylight Time) }
],
bundleId: [],
video:
[ { videoLocation: 'rtmp://xxxxxxxxxxxxxxxxxxx.cloudfront.net/cfx/st/vid_51323386'
,
thumbnailLocation: 'https://xxxxxxxxxxxxxxxxxxx.cloudfront.net/thumb_51323386.
png',
_id: 534ec5c98c4bf1be305fee20,
createDate: Wed Apr 16 2014 12:02:49 GMT-0600 (Mountain Daylight Time),
format: 'FLV' } ],
display: true,
active: true,
createDate: Wed Apr 16 2014 12:02:49 GMT-0600 (Mountain Daylight Time),
revision: 1,
scripts:
[ { _id: 534ec5c98c4bf1be305fee1f,
display: true,
active: true,
createDate: Wed Apr 16 2014 12:02:49 GMT-0600 (Mountain Daylight Time),
keyPoints: [],
body: [Object],
subject: [] } ],
presentation:
[ { pageLocation: null,
_id: 534ec5c98c4bf1be305fee21,
display: true,
active: true,
syncManifest: [],
pageNumber: [Object] } ],
subcategoryId: [ 53236dff2ab8b9182716f34d ],
categoryId: [ 532369bb2ab8b9182716f33d ],
authorId: [ 532c9a146ce0682319cebbf9 ] }

我注意到的一个区别是,我没有向它发送一个 ObjectID 数组,而是向它发送一个字符串数组,而不是像 Wed Apr 16 2014 12:02:49 GMT-0600 (Mountain Daylight时间) 我发送它 2014-04-16T18:02:49.454Z。那有关系吗?

最佳答案

修复它:

https://github.com/LearnBoost/mongoose/issues/1933

我明确地保存了 __v 属性,这是一个禁忌。

在我的循环中,我只是检查 p 是否等于 __v,如果是,我将忽略它。没问题了。

关于javascript - 蒙哥错误: Field name duplication not allowed with modifiers,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23119823/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com