Skip to content

GCP.Datastore reference

Source: src/GCP/Datastore/Commit.ts

Runtime binding for Datastore projects.commit.

Bind this operation to a Datastore-mode GCP.Firestore.Database in a Function/Action init phase. Provide CommitHttp. The bound database supplies the project and database id; mutations run against that database only. The host is granted the role on the project under an IAM Condition matching the database.

const database = yield* GCP.Firestore.Database("Tasks", {
type: "DATASTORE_MODE",
});
const commit = yield* GCP.Datastore.Commit(database);
const result = yield* commit({
body: {
mode: "NON_TRANSACTIONAL",
mutations: [
{
upsert: {
key: { path: [{ kind: "Task", name: "t1" }] },
properties: { title: { stringValue: "Ship" } },
},
},
],
},
});

Source: src/GCP/Datastore/CommitHttp.ts Kind: Layer · Provides: GCP.Datastore.Commit

HTTP implementation of Commit.

Source: src/GCP/Datastore/Indexes.ts

A Cloud Datastore composite index.

Indexes apply to the project’s default Datastore-mode database. The index id is assigned by the API. Kind, ancestor mode, and properties are immutable — changing them replaces the index. Indexes have no labels field, so Alchemy tracks an index by the id in state; without state an index with the same definition is adopted when its kind is the generated one and reported as unowned otherwise.

Composite index on a kind

const index = yield* GCP.Datastore.Index("TasksByDone", {
kind: "Task",
ancestor: "NONE",
properties: [
{ name: "done", direction: "ASCENDING" },
{ name: "priority", direction: "DESCENDING" },
],
});

Ancestor index

const index = yield* GCP.Datastore.Index("CommentsByCreated", {
kind: "Comment",
ancestor: "ALL_ANCESTORS",
properties: [
{ name: "created", direction: "DESCENDING" },
{ name: "author", direction: "ASCENDING" },
],
});

Source: src/GCP/Datastore/Lookup.ts

Runtime binding for Datastore projects.lookup.

Bind this operation to a Datastore-mode GCP.Firestore.Database in a Function/Action init phase. Provide LookupHttp. The bound database supplies the project and database id; lookups run against that database only. The host is granted the role on the project under an IAM Condition matching the database.

const database = yield* GCP.Firestore.Database("Tasks", {
type: "DATASTORE_MODE",
});
const lookup = yield* GCP.Datastore.Lookup(database);
const result = yield* lookup({
body: {
keys: [{ path: [{ kind: "Task", name: "t1" }] }],
},
});

Source: src/GCP/Datastore/LookupHttp.ts Kind: Layer · Provides: GCP.Datastore.Lookup

HTTP implementation of Lookup.

Source: src/GCP/Datastore/RunQuery.ts

Runtime binding for Datastore projects.runQuery.

Bind this operation to a Datastore-mode GCP.Firestore.Database in a Function/Action init phase. Provide RunQueryHttp. The bound database supplies the project and database id; queries run against that database only. The host is granted the role on the project under an IAM Condition matching the database.

const database = yield* GCP.Firestore.Database("Tasks", {
type: "DATASTORE_MODE",
});
const runQuery = yield* GCP.Datastore.RunQuery(database);
const page = yield* runQuery({
body: { query: { kind: [{ name: "Task" }] } },
});

Source: src/GCP/Datastore/RunQueryHttp.ts Kind: Layer · Provides: GCP.Datastore.RunQuery

HTTP implementation of RunQuery.