| 138 | } |
| 139 | |
| 140 | async delete(ids: string[]) { |
| 141 | if (ids.length <= 0) return; |
| 142 | |
| 143 | await this.db() |
| 144 | .transaction() |
| 145 | .execute(async (tx) => { |
| 146 | for (const chunk of toChunks(ids, MAX_SQL_PARAMETERS)) { |
| 147 | await tx |
| 148 | .deleteFrom<keyof DatabaseSchema>(this.type) |
| 149 | .where("id", "in", chunk) |
| 150 | .execute(); |
| 151 | } |
| 152 | }); |
| 153 | this.eventManager.publish(EVENTS.databaseUpdated, <DeleteEvent>{ |
| 154 | type: "delete", |
| 155 | collection: this.type, |
| 156 | ids |
| 157 | }); |
| 158 | } |
| 159 | |
| 160 | async exists(id: string) { |
| 161 | const { count } = |