Mongoose update not updating: { ok: 0, n: 0, nModified: 0 }

后端 未结 1 1883
情书的邮戳
情书的邮戳 2021-01-19 02:03

I have a collection named \"permissions\" on MongoDB. I want to implement a simple update like this:

let schema = new Schema({
    title: String
  });
  let          


        
1条回答
  •  梦毁少年i
    2021-01-19 02:37

    According to the docs

    Models are fancy constructors compiled from Schema definitions. An instance of a model is called a document. Models are responsible for creating and reading documents from the underlying MongoDB database.

    So you need to create instance during the .save() call only. Other operations(update, read, delete) applied on the existing document and hence, no need to create instance.

    0 讨论(0)
提交回复
热议问题