Is it possible to create a jsonPropertyScopeQuery in a JavaScript Query Generator Function?

12 Views Asked by At

I'm trying to create the following query based on a "search syntax": cts.jsonPropertyScopeQuery("status", cts.jsonPropertyScopeQuery("current", cts.jsonPropertyValueQuery("status", "Received", ["lang=en"], 1)))

To take it down to a single Scope, for example, I need this first: cts.jsonPropertyScopeQuery("current", cts.jsonPropertyValueQuery("status", "Received", ["lang=en"], 1))

So, I've tried the following, which just gives me an error:

'use strict';

let bindingsObject =
          {
            Scope: scope,
            StatusValue: statusValue,
          };   

function scope(operator, value, options) {
  let theProperty = fn.substringBefore(value, ":");
  let thePropertyTrimmed = theProperty.substring(1);
  let theRest = fn.substringAfter(value, ":");
  let theRestTrimmed = theRest.substring(0, theRest.length - 1);
  return cts.jsonPropertyScopeQuery(thePropertyTrimmed, cts.parse(theRestTrimmed, bindingsObject));
}

function statusValue(operator, value, options) {
  return cts.jsonPropertyValueQuery('status', value, ['exact']); 
}

//cts.parse('(StatusValue:Received)', bindingsObject)
cts.parse('(Scope:(current:(StatusValue:Received)))', bindingsObject)

The error being:

[javascript] XDMP-UNEXPECTED: cts.parse('(Scope:(current:(StatusValue:Received)))', bindingsObject) -- Unexpected token syntax error, unexpected PLpar_

The problem I can't really get ahold of what cts.parse() is doing to the main string. Putting things in parentheses makes sense to me to be able to group things, but I'm not conveying something correctly with the parenthesis and colons in order to be able to use cts.parse() recursively like this.

Thus, the basic question is: what "search syntax" would be parse-able by cts.parse() to enable the creation of a jsonPropertyScopeQuery?

0

There are 0 best solutions below