Skip to content

Collection methods: export, query

The Collection Verbs export, query as typed SDK methods, with inputs, result, refusals and an example.

Reference for Collection, one group of Collection methods.

Collection.export

Export writes a Collection’s records to a file or the Startup’s warehouse, once or on a schedule. Verb page.

TypeScript
interface CollectionVerbs {
  export(input: CollectionExportInput, options?: SB.CallOptions): SB.Call<CollectionExportOutput>
}

Emits Collection.exported.

Inputs

InputTypeRequiredDescription
collectionCollectionrequiredThe Collection to export.
tostringrequiredA file format, or the warehouse Integration that receives it.
cadencestringHow often it repeats; omitted, it runs once.

Returns

OutputTypeRequiredDescription
fileFileThe exported File, for a one-time export.
collectionCollectionrequiredThe Collection exported.

Refuses when

CheckErrorFixThen call
The key is valid, but its scopes do not allow this operation.forbiddenUse a key whose scopes cover the operation, or ask an owner of the namespace to grant them.None.

Example

TypeScript
import { $ } from 'startup-builder'

const { file, collection } = await $.Collection.export({ collection: 'collection_txTK8QorKn', to: 'Example to' })

Collection.query

Query reads any Nouns the caller’s Permissions allow, by SQL or a Relationship path, across every System in one call. Verb page.

TypeScript
interface CollectionVerbs {
  query(input: CollectionQueryInput, options?: SB.CallOptions): SB.Call<CollectionQueryOutput>
}

Emits Collection.queried.

Inputs

InputTypeRequiredDescription
querytextrequiredSQL, or a Relationship path such as customer.subscriptions.invoices.
savebooleanTrue saves it as a Collection defined by the query.

Returns

OutputTypeRequiredDescription
rowsjsonrequiredThe matching records.
collectionCollectionrequiredThe Collection the query read.

Refuses when

CheckErrorFixThen call
The key is valid, but its scopes do not allow this operation.forbiddenUse a key whose scopes cover the operation, or ask an owner of the namespace to grant them.None.

Example

TypeScript
import { $ } from 'startup-builder'

const { rows, collection } = await $.Collection.query({ query: 'Example query' })