( data: z.infer<typeof zChannelUpdateMany>[], )
| 267 | } |
| 268 | |
| 269 | export async function updateManyChannels( |
| 270 | data: z.infer<typeof zChannelUpdateMany>[], |
| 271 | ) { |
| 272 | const dataReturned: Channel[] = []; |
| 273 | for await (const channel of data) { |
| 274 | await db |
| 275 | .update(dbChannels) |
| 276 | .set(channelInsertSchema.parse(channel)) |
| 277 | .where(eq(dbChannels.id, channel.id)); |
| 278 | |
| 279 | const updated = await db.query.dbChannels.findFirst({ |
| 280 | where: eq(dbChannels.id, channel.id), |
| 281 | }); |
| 282 | if (!updated) throw new Error('Error updating channel'); |
| 283 | dataReturned.push(updated); |
| 284 | } |
| 285 | return dataReturned; |
| 286 | } |
| 287 | |
| 288 | export async function deleteChannel(id: string) { |
| 289 | await deleteManyMessagesByChannelId(id); |
no test coverage detected