我知道如何在 Feathers ( systemService.create(category);
) 中创建东西,但是如何在子集合中创建东西?
我想插入category
,systemService[0].productCategories
但还没有弄清楚如何做到这一点。这是我的服务的屏幕截图。
有人对我应该如何进行有任何提示吗?
编辑:找到一个几乎可行的解决方案。
systemService.find((error, categories) => {
const $id = categories[0]._id;
systemService.update($id, {
"$set": {
"productCategories": [
newCategory
]
}
});
console.log(categories);
});
但是,它只是替换已经存在的内容productCategories
,而不是添加到其中。我试过patch
了,但什么也没发生(所以我可能做错了,或者这不是答案)。