MCPcopy
hub / github.com/aspen-cloud/triplit / clearDB

Method clearDB

packages/server-core/src/session.ts:65–81  ·  view source on GitHub ↗
({ full }: { full?: boolean })

Source from the content-addressed store, hash-verified

63
64 // TODO: ensure data that we store in memory is invalidated when the db is "cleared"
65 async clearDB({ full }: { full?: boolean }) {
66 if (!hasAdminAccess(this.token)) return NotAdminResponse();
67 try {
68 await this.db.clear({ full });
69 // clear will reset ivm, this will rebroadcast the empty server queries
70 if (!full) {
71 await this.db.updateQueryViews();
72 this.db.broadcastToQuerySubscribers();
73 }
74 return ServerResponse(200);
75 } catch (e) {
76 if (isTriplitError(e)) return this.errorResponse(e);
77 return this.errorResponse(e, {
78 fallbackMessage: 'An unknown error occurred clearing the database.',
79 });
80 }
81 }
82
83 async getCollectionStats() {
84 if (!hasAdminAccess(this.token)) return NotAdminResponse();

Callers 1

handleRequestMethod · 0.80

Calls 8

errorResponseMethod · 0.95
hasAdminAccessFunction · 0.85
NotAdminResponseFunction · 0.85
ServerResponseFunction · 0.85
isTriplitErrorFunction · 0.85
updateQueryViewsMethod · 0.80
clearMethod · 0.65

Tested by

no test coverage detected