How to Realize Traversal Update in mongoose chain operation?

  node.js, question
var todoListSchema = mongoose.Schema({
 name: {type: String}
 , tag: {type: String}
 , createDate: {type: Date}
 , endDate: {type: Date} // due date
 , content: {type: String}
 , done: {type: Boolean}
 , remainedate: {type: number}//days remaining
 var todoList = mongoose.model('todos', todoListSchema);

The above is ToDoList Schema designed by me. When querying someone’s ToDoList, I intend to update and save the value of endDate and finally output the result.

Express-promise is a module that enables the mongoose query code of the render template inside to be executed immediately, so I tried to play this special skill and used it …

// app.js uses this module

However, the following code makes it difficult … I try to construct a method to update and save remainDate for Schema. If I place the method between the find operation and the sort operation, I will report that the constructed method is not a function. Can we only use callbacks to write? ? ?

//Want to know how to implement the code similar to the following
 Todos: todolist.find ({name: req.session.user}). (update and save each todo after filtering according to the difference between endDate and current time). sort().exec ()

Mongoose has a pre hook for find’