mongoose virtual field promise return value -


i in virtual field return value calculated in promise:

countryschema     .virtual('citycounter')     .get(function () {         var counter;         var id = this._id;         city             .count({ country: id })             .then(function (count) {                 counter = count;                 console.log(id + ' ' + counter);                  return counter;             })             .catch(function (err) {                 console.log(err);             });     }); 

but nothing returned. in promise, counter correctly populated don't know how retrieve data in get.

how ? thank you.


Comments

Popular posts from this blog

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -