我有一个文档IDarray.数组是有序的,我想要更新所有匹配文档的一个固定的order
%.值order
应为数组中的位置.
目前,我做了以下工作,这些工作都很好:
const result = await this.collection.bulkWrite(
orderedIncices.map((_id, index: number) => ({
updateOne: {
filter: { _id },
update: { $set: { order: index } },
},
})),
);
我想知道有没有更有效的方法.