arangodb - Object Array data type -


this aql returns object use.

const keys = db._query(aql`     huis in test     filter huis._key in ${req.queryparams.keys}     return {         'key': huis._key,         'adres': huis.adres,         'postcode': huis.postcode,         'plaats': huis.plaats     } `); 

this returns object:

[   {     "key": "374875",     "adres": "klaverstraat 7",     "postcode": "2197gv",     "plaats": "leiden"   } ] 

then take key so:

keys[0].key 

this works in javascript when make fiddle not in foxx.

const test = [   {     "key": "374875",     "adres": "klaverstraat 7",     "postcode": "2197gv",     "plaats": "leiden"   } ]  console.log(test[0].key) 

374875

why return 'undefined' in foxx correct data in fiddle?

this foxx code:

router.get('/', function (req, res) {   const test = [     {       "key": "374875",       "adres": "klaverstraat 7",       "postcode": "2197gv",       "plaats": "leiden"     }   ];    console.log(test[0].key);   res.status(200).send(test[0]); }, 'test1')   .summary('test1')   .description('test1'); 

returns via rest:

{   "key": "374875",   "adres": "klaverstraat 7",   "postcode": "2197gv",   "plaats": "leiden" } 

logs arangodb logs:

374875

when getting data via query, need make sure query completed before read contents of result.

look @ code:

router.get('/', function (req, res) {   const keys = db._query(aql`     huis in test     filter huis._key == "374875"     return {         'key': huis._key,         'adres': huis.adres,         'postcode': huis.postcode,         'plaats': huis.plaats     } `).toarray();    console.log(keys[0].key);    res.status(200).send(keys);  }, 'test1')   .summary('test1')   .description('test1'); 

here filter condition has been changed, , .toarray() added after query has executed. makes sure query complete , contents of keys you'd expect.


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -