I\'m developping an express js API with mongo DB and mongoose.
I would like to create an object in Javascript es6 composed of few variables and the result of a mongo
You can use the Mongoose Document.toObject() method. It will return the underlying plain JavaScript object fetched from the database.
Document.toObject()
const newObject = {...result.toObject(), toto: "toto"};
You can read more about the .toObject() method here.
.toObject()