({ full }: { full?: boolean })
| 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(); |
no test coverage detected