MongoError:修饰符不允许使用字段名称重复

注:据我所知,我不是在做stream行的东西。

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

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 ] } 

我注意到的一个区别是,而不是发送一个ObjectIDs数组,我发送一个string数组,而不是像Wed Apr 16 2014 12:02:49 GMT-0600 (Mountain Daylight Time)我发送2014-04-16T18:02:49.454Z 。 那会很重要吗?

修复:

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

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

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