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
Post a Comment