Created
November 15, 2016 08:41
-
-
Save nishantsingh1/ca063f3a2f625aa5c8d2d034acf9f85b to your computer and use it in GitHub Desktop.
Node.js example 2: a simple QBE for range queries using filtered search and sorting on company property 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')) | |
) | |
.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