Created
November 15, 2016 08:45
-
-
Save nishantsingh1/48581f9d0b7efe6e34bc2e7dc8180fd3 to your computer and use it in GitHub Desktop.
Node.js example 3: QBE for range queries using filtered search and sorting on company and path '/location/type'
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('company',q.sort(q.pathIndex('/location/type'))) | |
) | |
.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