简体   繁体   中英

Gremlin query: how to specify sort order in javascript

I am using AWS Neptune.

I want to perform a simple gremlin query that returns vertices sorted in decreasing order by a property named "timestamp".

I can do this using the gremlin console:

gremlin> gV().has('timestamp').order().by('timestamp', desc).fold()

But when I use this same statement from my nodejs application, I get the error "ReferenceError: desc is not defined". I am not surprised by the error, since I have not defined "desc".

My question: how do I pass the sort order in the gremlin query?

Am I missing an import?

I tried passing in the string 'desc' -- that didn't work.

I think you're just missing an import - in 3.3.3 :

const gremlin = require('gremlin');
const order = gremlin.process.order;

You can read more about it here . Note that 3.3.4 which is not yet released officially will have support for desc and asc as opposed to decr and incr .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM