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.
Latest
class Datastore
import { Datastore } from "https://deno.land/x/google_datastore@0.2.1/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.

query<T>(query: Query | QueryRequestGenerator): Promise<(T & EntityMetaData)[]>

Run a query and convert the return entities to objects, resolving with an array containing all the results.

If an error occurs, the promise will be rejected with an instance of DatastoreError containing more information about the error.

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 aggregations.

Queries for entities.

Queries for entities.

Perform a query and return the entities as a stream.

Static Properties

readonly
SCOPES: string

The scopes provided when obtaining an API token.

Static Methods

key(...keyInit: KeyInit[]): Key

Generate a key.