Hi,

I’ve got a problem with querying data using QBE from nodeJS.

The following code works fine. It returns data that fits my example from the 
specified collection.

var query = client.qb.where(
           client.qb.byExample(
               {
                   "isin": params.isin
               }
           )
       );

       client.queryCollection(
           config.MARKLOGIC_STATIC_COL_NAME,
           query
       ).result(
           function (docs) {
               if (docs.length >= 1) {
                   queryResults[queryResults.length] = docs[0];
                   FetchLastPrice(docs[0].sedol, 1);
               } else {
                   LogWrite('Unable to find static document for isin "' + 
params.isin + '"');
                   next(errResult);
               }
           },
           function (err) {
               LogWrite(JSON.stringify(err, null, 4));
               next(errResult);
           }
       );

Once I add an orderBy statement (highlighted) the REST service starts returning 
documents that fit my example not only from the specified collection but from 
all collections in my database.

var query = client.qb.where(
           client.qb.byExample(
               {
                   "isin": params.isin
               }
           )
       ).orderBy(client.qb.sort('validStart', 'descending'));

       client.queryCollection(
           config.MARKLOGIC_STATIC_COL_NAME,
           query
       ).result(
           function (docs) {
               if (docs.length >= 1) {
                   queryResults[queryResults.length] = docs[0];
                   FetchLastPrice(docs[0].sedol, 1);
               } else {
                   LogWrite('Unable to find static document for isin "' + 
params.isin + '"');
                   next(errResult);
               }
           },
           function (err) {
               LogWrite(JSON.stringify(err, null, 4));
               next(errResult);
           }
       );

How can I fix it up?

_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to