javascript - Transfer entities to JSON format on Google Datastore -
i'm trying count how many entities in datastore,
const query = datastore.createquery('testname','testkind') .filter('done', '=' , false) .order('innerid',{ descending: true}); var datalist; const rquery = datastore.runquery(query) .then((results) => { datalist = results[0]; });
just example use query fetch entities want.
however, when try count how many entities there, it's quite difficult. if use app.get('/', (req, res) => { res.json(datalist); });
, shows normal form of json.
but, when try count numbers outside read request, console.log(datalist);
it shows undefined
....
then tried const par = json.parse(datalist); console.log(par);
it shows syntaxerror: unexpected token u in json @ position 0
any tips solve problem? or maybe misunderstand something?
but, when try count numbers outside read request,
i think that's problem. you'll have wait variable populated before can access it.
Comments
Post a Comment