How to use the @google-cloud/datastore 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 sebelga / google-datastore-blog-app / src / server / db.ts View on Github external
export default ({ config, logger }: { config: GcloudConfig; logger: Logger }): Gstore => {
  logger.info(`Instantiating Datastore instance`);
  logger.info(`Google Cloud project: ${config.projectId}`);
  logger.info(`Datastore namespace: ${config.datastore.namespace}`);

  /**
   * Create Datastore client instance
   */
  const datastore = new Datastore({
    projectId: config.projectId,
    namespace: config.datastore.namespace,
  });

  /**
   * Create gstore instance
   */
  const gstore = GstoreNode({ cache: true });

  /**
   * Connect gstore to the Google Datastore instance
   */
  logger.info('Connecting gstore-node to Datastore');
  gstore.connect(datastore);

  return gstore;
github GoogleCloudPlatform / js-data-cloud-datastore / src / index.js View on Github external
* @property {string} projectId Google Cloud Platform project id.
   */
  this.datastoreOpts || (this.datastoreOpts = {});
  utils.fillIn(this.datastoreOpts, DATASTORE_DEFAULTS);

  /**
   * Override the default predicate functions for the specified operators.
   *
   * @name CloudDatastoreAdapter#operators
   * @type {object}
   * @default {}
   */
  this.operators || (this.operators = {});
  utils.fillIn(this.operators, OPERATORS);

  this.datastore || (this.datastore = Datastore(this.datastoreOpts));
}