Created
November 15, 2016 08:47
-
-
Save nishantsingh1/a2f7f077bcd636485ac75593afe0d05d to your computer and use it in GitHub Desktop.
Node.js example 4: QBE for range queries sorting on company and path '/location/type' in descending order
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var marklogic = require("marklogic"); | |
var conn = require("./env.js").connection; | |
//create DatabaseClient | |
var db = marklogic.createDatabaseClient(conn); | |
var q = marklogic.queryBuilder; | |
db.documents.query( | |
q.where( | |
q.byExample( | |
{ | |
age: { $gt: 10 }, | |
$filtered: true | |
} | |
) | |
) | |
.orderBy(q.sort('company', 'descending'),q.sort(q.pathIndex('/location/type'),'descending')) | |
) | |
.stream(). | |
on("data", function(document) { | |
console.log(document); | |
}). | |
on("error", function(error) { | |
console.error(error) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment