我有一个现有的“子实体”,当我创建一个新的“父实体”时,我想将现有的子实体与新的子实体相关联。
async createParent(fieldOne: string, fieldTwo: string, existentChild) {
const newParent = await this.defaultRepository.create({
fieldOne,
fieldTwo
});
newParent.children = [existentChild];
return this.defaultRepository.save(newParent);
}
我收到此错误
MongoError: '$set' is empty. You must specify a field like so: {$set: {<field>: ...}}