How to use the @google-cloud/datastore.Datastore.NO_MORE_RESULTS function in @google-cloud/datastore

To help you get started, we’ve selected a few @google-cloud/datastore 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 googleapis / nodejs-datastore / samples / concepts.js View on Github external
async function runPageQuery(pageCursor) {
      let query = datastore.createQuery('Task').limit(pageSize);

      if (pageCursor) {
        query = query.start(pageCursor);
      }
      const results = await datastore.runQuery(query);
      const entities = results[0];
      const info = results[1];

      if (info.moreResults !== Datastore.NO_MORE_RESULTS) {
        // If there are more results to retrieve, the end cursor is
        // automatically set on `info`. To get this value directly, access
        // the `endCursor` property.
        const results = await runPageQuery(info.endCursor);

        // Concatenate entities
        results[0] = entities.concat(results[0]);
        return results;
      }

      return [entities, info];
    }
    // [END datastore_cursor_paging]
github sahava / GoogleTagManagerTemplates_site / models / template-db.js View on Github external
const list = async (limit, token, orderBy) => {
  const order = orderBy || 'views';
  const q = ds
    .createQuery([kind])
    .limit(limit)
    .order(order, {descending: true})
    .start(token);

  const [rows, nextQuery] = await ds.runQuery(q);
  return {
    templates: rows.map(fromDatastore),
    hasMore: nextQuery.moreResults !== Datastore.NO_MORE_RESULTS
      ? nextQuery.endCursor
      : false
  };
};
github GoogleCloudPlatform / nodejs-getting-started / 4-auth / books / model-datastore.js View on Github external
ds.runQuery(q, (err, entities, nextQuery) => {
    if (err) {
      cb(err);
      return;
    }
    const hasMore =
      nextQuery.moreResults !== Datastore.NO_MORE_RESULTS
        ? nextQuery.endCursor
        : false;
    cb(null, entities.map(fromDatastore), hasMore);
  });
}
github GoogleCloudPlatform / nodejs-getting-started / 2-structured-data / books / model-datastore.js View on Github external
ds.runQuery(q, (err, entities, nextQuery) => {
    if (err) {
      cb(err);
      return;
    }
    const hasMore =
      nextQuery.moreResults !== Datastore.NO_MORE_RESULTS
        ? nextQuery.endCursor
        : false;
    cb(null, entities.map(fromDatastore), hasMore);
  });
}
github GoogleCloudPlatform / nodejs-getting-started / optional-kubernetes-engine / books / model-datastore.js View on Github external
ds.runQuery(q, (err, entities, nextQuery) => {
    if (err) {
      cb(err);
      return;
    }
    const hasMore =
      nextQuery.moreResults !== Datastore.NO_MORE_RESULTS
        ? nextQuery.endCursor
        : false;
    cb(null, entities.map(fromDatastore), hasMore);
  });
}
github GoogleCloudPlatform / nodejs-getting-started / 7-gce / books / model-datastore.js View on Github external
ds.runQuery(q, (err, entities, nextQuery) => {
    if (err) {
      cb(err);
      return;
    }
    const hasMore =
      nextQuery.moreResults !== Datastore.NO_MORE_RESULTS
        ? nextQuery.endCursor
        : false;
    cb(null, entities.map(fromDatastore), hasMore);
  });
}
github GoogleCloudPlatform / nodejs-getting-started / 3-binary-data / books / model-datastore.js View on Github external
ds.runQuery(q, (err, entities, nextQuery) => {
    if (err) {
      cb(err);
      return;
    }
    const hasMore =
      nextQuery.moreResults !== Datastore.NO_MORE_RESULTS
        ? nextQuery.endCursor
        : false;
    cb(null, entities.map(fromDatastore), hasMore);
  });
}