Hi I am now using gremlin -javascript to do some queries in AWS neptune DB. I have a query like
[errRelatedTicket, relatedTicket] = await to(g.V().hasId(a).in_('r').valueMap(true).toList());
then I get a list of map like:
[
Map {
id: 1
},
Map {
id: 2
},
]
But can I use gremlin query to get id and properties in key/value pairs directly instead? what I expect is:
[
{ id: 1 },
{ id: 2 },
]
I don't know "gremlin-javascript", you can research more in the document. But I know there's a simple way to do the conversion in plain javascript, use .map and Object.fromEntries. Hope you'll find a better way.
var listMap = [
new Map([[ 'id', 1 ]]),
new Map([[ 'id', 2 ]]),
];
var listObject = listMap.map(m => Object.fromEntries(m));
console.log(listObject);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With