Skip to main content
Module

x/google_datastore/mod.ts>Datastore

A set of APIs that allow interfacing to Google Datastore on GCP from Deno.
Go to Latest
class Datastore
import { Datastore } from "https://deno.land/x/google_datastore@0.0.14/mod.ts";

An interface to Google Datastore. This is the main class users should use to connect to a Google Datastore instance.

Example

import { Datastore } from "https://deno.land/x/google_datastore/mod.ts";
import keys from "./service-account.json" assert { type: "json" };

const datastore = new Datastore(keys);

const result = await datastore.query({ kind: "book" });

Constructors

new
Datastore(datastoreInit: DatastoreInit)

Properties

readonly
indexes: DatastoreIndexes

APIs related to creating and managing indexes.

readonly
operations: DatastoreOperations

APIs related to managing operations (long running processes).

Methods

allocateIds(...keys: Key[]): Promise<Key[]>

Allocates IDs for the given keys, which is useful for referencing an entity before it is inserted.

beginTransaction(transactionOptions?: TransactionOptions): Promise<string>

Begins a new transaction.

commit(mutations: Mutation[], options?: CommitOptions): AsyncIterableIterator<CommitResponse>

Commits a transaction, optionally creating, deleting or modifying some entities.

An async iterable that yields up each commit response for each batch of mutations being sent.

createQuery(kind?: string | string[]): Query

Create a query.

createQuery(namespace: string, kind: string | string[]): Query
key(...keyInit: KeyInit[]): Key

Generate a key.

lookup(keys: Key | Key[], readOptions?: ReadOptions): Promise<LookupResponse>

Looks up entities by key.

reserveIds(keys: Key[], databaseId?: string): Promise<void>

Prevents the supplied keys' IDs from being auto-allocated by Cloud Datastore.

rollback(transaction: string): Promise<void>

Rolls back a transaction.

Queries for entities.

Queries for entities.

Perform a query and return the entities as a stream.

Static Properties

readonly
API_ROOT: string

The root of the API endpoint. Used when forming request URLs.

readonly
SCOPES: string

The scopes provided when obtaining an API token.