I'm trying to Promisify the following function
let Definition = mongoose.model('Definition', mySchema)
let saveDefinition = (newDefinition) => {
var newDef = new Definition(newDefinition);
newDef.save();
return Definition.find();
}
to achieve the following sequence of events
let saveDefinition = (newDefinition) => {
return = new Promise((res, rej) => {
// newDef = new Definition(newDefinition)
// then
// newDef.save()
// then
// return Definition.find()
})
}
The goal is to invoke this function upon a request from the client, save a document to the model called "Definition" and return all of the documents within the model back to to the client. Any help or guidance would be greatly appreciated.
I'm not really sure on how to approach the problem