컬렉션의 기존 배열로 푸시하여 컬렉션을 업데이트하려고합니다.미터가 컬렉션에 배열에 새 객체를 푸시
update failed: MongoError: Cannot update 'players' and 'players' at the same time
관련 스키마 :
Player = new SimpleSchema({
name: {
type: String,
label: 'name',
max: 50,
},
});
Schemas.Game = new SimpleSchema({
...
players: {
type: [Player],
label: 'Players',
autoValue: function() {
return [];
},
},
});
여기
Games.update({ _id: game._id }, {
$push: { players: { name: playerName } },
});
내가 콘솔에서 점점 오전 오류입니다 : 여기
내가 실행하려고하고있는 업데이트 기능입니다
players
배열의 경우
autoValue
을 사용하여 배열을 초기화 할 때 정렬합니다. 새로운 게임이 만들어집니다. 첫 번째 플레이어가 추가 될 때 이것이 문제가 될 수 있습니까?
일부 도움을 주시면 감사하겠습니다.
사용하는 것입니다. autoValue 대신 defaultValue를 사용하여 처리 할 수있었습니다. 원하는 모든 것이 속성을 초기화하는 것이라면 defautValue가 원하는 것입니다. –