get: function (code) {
console.log('Retrieving model for code : ', code);
let database = UTILS.getDatabase('databaseName');
return database.models.modelName.find({})
.then(function (users) {
console.log(' ----------- ', users);
return users;
})
.catch(function (error) {
return '{success: "false", msg: "Error found : ' + error + '"}';
});
}
This code is running without any error, but function which call "get" couldn't find any record, while callback function prints around 8-9 records in console.
I know this is callback functionality, but I need this to be happen sequential.
I also tried to use yield "return yield database.models.modelName.find({})" with * function, but getting {} empty object.
please suggest me a way to avoid callback and get data from mongodb.
Thanks
via Himkar dwivedi
No comments:
Post a Comment