我正在尝试在 mongo 的 Grid fs 中向文件对象添加一个元数据。但它没有在 Gridfs 中更新(实际上我正在添加名为 page 的新属性)元数据。
以下是我的代码,在保存文档后,它会尝试使用其他属性更新该文件。
fs.createReadStream(file)
.pipe(bucket.openUploadStream(documentId.toString()))
.on('finish', async (savedFile: File) => {
let page = 1;
const letssee = await FilesModel(
projectContext,
bucketName,
).findById(savedFile._id); // findById is working.
await FilesModel(
projectContext,
bucketName,
).findByIdAndUpdate(savedFile._id, { $set: { page } }); // findByIdAndUpdate is not working.
});
我在这里做错了什么?或者只是 Grid Fs 对象不支持元数据更新?