How to use the marklogic.queryBuilder.directory function in marklogic

To help you get started, we’ve selected a few marklogic examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github marklogic-community / marklogic-samplestack / appserver / node-express / lib / db-client / contributor / old / getContributor.js View on Github external
//   )
    // ).result(
    //
    var fetch;

    if (userSpec.contributorId) {
      fetch = self.documents.read(
        'com.marklogic.samplestack.domain.Contributor/' +
            userSpec.contributorId +
            '.json'
      );
    }
    else {
      fetch = self.documents.query(
        qb.where(
          qb.directory('com.marklogic.samplestack.domain.Contributor/'),
          qb.value('userName', userSpec.uid)
        )
      );
    }
    fetch.result(
      function (response) {
        if (response.length !== 1) {
          return reject({
            error: 'cardinalityViolation',
            userSpec: userSpec,
            count: response.length
          });
        }
        var obj = response[0].content[
          Object.keys(response[0].content)[0]
        ];
github marklogic-community / marklogic-samplestack / appserver / node-express / lib / db-client / qnaDoc / old / getQuestions.js View on Github external
return new Promise(function (resolve, reject) {

    var questionsDir = '/questions/';
    var length = 10;
    var start = (userSpec.start) ? parseInt(userSpec.start) : 1;
    var searchText = (userSpec.q) ? userSpec.q : '';
    var fetch = self.documents.query(
      qb.where(
        qb.directory(questionsDir),
        qb.parsedFrom(searchText)
      ).slice(start,length).withOptions({categories: 'none'})
    );
    fetch.result(
      function (response) {
        if (response.length !== 1) {
          return reject({
            error: 'cardinalityViolation',
            userSpec: userSpec,
            count: response.length
          });
        }
        return resolve(response);
      },
      reject
    );
github marklogic-community / marklogic-samplestack / appserver / node-express / lib / db-client / contributor / old / searchContributors.js View on Github external
return new Promise(function (resolve, reject) {

    var contributorsDir = 'com.marklogic.samplestack.domain.Contributor/';
    var length = 10;
    var start = (userSpec.start) ? userSpec.start : 1;
    var searchText = (userSpec.q) ? userSpec.q : '';
    var fetch = self.documents.query(
      qb.where(
        qb.directory(contributorsDir),
        qb.parsedFrom(searchText)
      ).slice(start,length).withOptions({categories: 'none'})
    );
    fetch.result(
      function (response) {
        if (response.length !== 1) {
          return reject({
            error: 'cardinalityViolation',
            userSpec: userSpec,
            count: response.length
          });
        }
        return resolve(response);
      },
      reject
    );