findByIdAndUpdate 不适用于 GridFs 对象

findByIdAndUpdate is not working with GridFs Object

我正在尝试向 mongo 中的 Grid fs 中的文件对象添加一个元数据。但它没有在 Gridfs 中更新(实际上我正在添加新的 属性 称为页面)元数据。

以下是我的代码,在保存文档后,它会尝试使用其他 属性.

更新该文件
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 对象不支持元数据更新?

根据评论,解决方案是:

尝试在 findByIdAndUpdate 查询后添加 .exec()

await Model.find().exec()

一样使用