Skip to content

Instantly share code, notes, and snippets.

@nishantsingh1
Created November 15, 2016 08:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nishantsingh1/ca063f3a2f625aa5c8d2d034acf9f85b to your computer and use it in GitHub Desktop.
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
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