API reference
classes
Triplitclient

Class: TriplitClient<M>

Type parameters

NameType
Mextends Models<any, any> | undefined = undefined

Constructors

constructor

new TriplitClient<M>(options?): TriplitClient<M>

Type parameters

NameType
Mextends undefined | Models<any, any> = undefined

Parameters

NameType
options?ClientOptions<M>

Returns

TriplitClient<M>

Defined in

packages/client/src/triplit-client.ts:216 (opens in a new tab)

Properties

authOptions

authOptions: AuthOptions

Defined in

packages/client/src/triplit-client.ts:209 (opens in a new tab)


db

db: default<M>

Defined in

packages/client/src/triplit-client.ts:203 (opens in a new tab)


defaultFetchOptions

Private defaultFetchOptions: Object

Type declaration

NameType
fetchFetchOptions
subscriptionSubscriptionOptions

Defined in

packages/client/src/triplit-client.ts:211 (opens in a new tab)


syncEngine

syncEngine: SyncEngine

The sync engine is responsible for managing the connection to the server and syncing data

Defined in

packages/client/src/triplit-client.ts:208 (opens in a new tab)

Methods

delete

delete<CN>(collectionName, entityId): Promise<undefined | string>

Type parameters

NameType
CNextends any

Parameters

NameType
collectionNameCN
entityIdstring

Returns

Promise<undefined | string>

Defined in

packages/client/src/triplit-client.ts:392 (opens in a new tab)


fetch

fetch<CQ>(query, options?): Promise<ClientFetchResult<CQ>>

Type parameters

NameType
CQextends ClientQuery<M, any>

Parameters

NameType
queryCQ
options?FetchOptions

Returns

Promise<ClientFetchResult<CQ>>

Defined in

packages/client/src/triplit-client.ts:289 (opens in a new tab)


fetchById

fetchById<CN>(collectionName, id, options?): Promise<undefined | ResultTypeFromModel<ModelFromModels<M, CN>>>

Type parameters

NameType
CNextends any

Parameters

NameType
collectionNameCN
idstring
options?FetchOptions

Returns

Promise<undefined | ResultTypeFromModel<ModelFromModels<M, CN>>>

Defined in

packages/client/src/triplit-client.ts:342 (opens in a new tab)


fetchLocal

fetchLocal<CQ>(query): Promise<ClientFetchResult<CQ>>

Type parameters

NameType
CQextends ClientQuery<M, any>

Parameters

NameType
queryCQ

Returns

Promise<ClientFetchResult<CQ>>

Defined in

packages/client/src/triplit-client.ts:334 (opens in a new tab)


fetchOne

fetchOne<CQ>(query, options?): Promise<null | [string, ClientFetchResultEntity<CQ>]>

Type parameters

NameType
CQextends ClientQuery<M, any>

Parameters

NameType
queryCQ
options?FetchOptions

Returns

Promise<null | [string, ClientFetchResultEntity<CQ>]>

Defined in

packages/client/src/triplit-client.ts:352 (opens in a new tab)


insert

insert<CN>(collectionName, object): Promise<undefined | string>

Type parameters

NameType
CNextends any

Parameters

NameType
collectionNameCN
objectInsertTypeFromModel<ModelFromModels<M, CN>>

Returns

Promise<undefined | string>

Defined in

packages/client/src/triplit-client.ts:363 (opens in a new tab)


query

query<CN>(collectionName): toBuilder<ClientQuery<M, CN>, "collectionName", QUERY_INPUT_TRANSFORMERS<ModelFromModels<M, CN>>>

Type parameters

NameType
CNextends any

Parameters

NameType
collectionNameCN

Returns

toBuilder<ClientQuery<M, CN>, "collectionName", QUERY_INPUT_TRANSFORMERS<ModelFromModels<M, CN>>>

Defined in

packages/client/src/triplit-client.ts:283 (opens in a new tab)


subscribe

subscribe<CQ>(query, onResults, onError?, options?): () => void

Type parameters

NameType
CQextends ClientQuery<M, any>

Parameters

NameType
queryCQ
onResults(results: ClientFetchResult<CQ>, info: { hasRemoteFulfilled: boolean }) => void
onError?(error: any) => void
options?SubscriptionOptions

Returns

fn

▸ (): void

Returns

void

Defined in

packages/client/src/triplit-client.ts:406 (opens in a new tab)


transact

transact(callback): Promise<undefined | string>

Parameters

NameType
callback(tx: DBTransaction<M>) => Promise<void>

Returns

Promise<undefined | string>

Defined in

packages/client/src/triplit-client.ts:272 (opens in a new tab)


update

update<CN>(collectionName, entityId, updater): Promise<undefined | string>

Type parameters

NameType
CNextends any

Parameters

NameType
collectionNameCN
entityIdstring
updater(entity: UpdateTypeFromModel<ModelFromModels<M, CN>>) => void | Promise<void>

Returns

Promise<undefined | string>

Defined in

packages/client/src/triplit-client.ts:376 (opens in a new tab)


updateOptions

updateOptions(options): void

Parameters

NameType
optionsPick<ClientOptions<M>, "token" | "serverUrl">

Returns

void

Defined in

packages/client/src/triplit-client.ts:548 (opens in a new tab)


updateServerUrl

updateServerUrl(serverUrl): void

Parameters

NameType
serverUrlstring

Returns

void

Defined in

packages/client/src/triplit-client.ts:582 (opens in a new tab)


updateToken

updateToken(token): void

Parameters

NameType
tokenstring

Returns

void

Defined in

packages/client/src/triplit-client.ts:578 (opens in a new tab)