Skip to content

Commit

Permalink
client: add clear method to clients
Browse files Browse the repository at this point in the history
  • Loading branch information
pbohlman committed Jun 25, 2024
1 parent 767bb51 commit d7b2190
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/rare-pets-prove.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@triplit/client': patch
---

add `clear` method to client and workerclient
4 changes: 4 additions & 0 deletions packages/client/src/client/triplit-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,10 @@ export class TriplitClient<M extends ClientSchema | undefined = undefined> {
return result;
}

async clear() {
return this.db.clear();
}

async fetchOne<CQ extends ClientQuery<M, any>>(
query: CQ,
options?: Partial<FetchOptions>
Expand Down
3 changes: 3 additions & 0 deletions packages/client/src/worker-client/worker-client-operator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ const workerOperator: ClientWorker = {
) {
return clientOperator.db.updateGlobalVariables(...args);
},
async clear() {
return await clientOperator.clear();
},
};

async function normalizeSubscriptionOptions(
Expand Down
5 changes: 5 additions & 0 deletions packages/client/src/worker-client/worker-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,4 +341,9 @@ export class WorkerClient<M extends ClientSchema | undefined = undefined> {
await this.initialized;
return this.clientWorker.rollback(txIds);
}

async clear() {
await this.initialized;
return this.clientWorker.clear();
}
}

0 comments on commit d7b2190

Please sign in to comment.