This is my implementation of Fawn in my project. I am using it to take an input object and add it to one collection as a new document and then update another collection with some of its values:
var task = fawn.Task();
task.save(
dbPost,
{
_id: new mongoose.Types.ObjectId(),
title: args.title,
content: args.content,
author: {
id: args.author_id,
first_name: args.author_first_name,
last_name: args.author_last_name,
}
}
);
task.update(
dbUser,
{ _id: args.author_id },
{$push: {posts:
{
id: {$ojFuture: "0._id"},
title: args.title,
content: args.content,
}
}}
);
task.run({useMongoose: true})
.then(function(){
// task is complete
console.log('done');
// value returned by task.save()
console.log('results');
})
.catch(function(err){
// Everything has been rolled back.
console.log(err);
Here, in the .then() block, I somehow need access to the data returned by task.save() (where it says console.log('results')). How can I do this? console.log($ojFuture) obviously returns an undefined error.
This is my implementation of Fawn in my project. I am using it to take an input object and add it to one collection as a new document and then update another collection with some of its values:
Here, in the
.then()
block, I somehow need access to the data returned bytask.save()
(where it saysconsole.log('results')
). How can I do this?console.log($ojFuture)
obviously returns an undefined error.