- Abstract shared sql code to a new drizzle package - Adds sqlite package, not ready to publish until drizzle patches some issues - Add `transactionOptions` to allow customizing or disabling db transactions - Adds "experimental" label to the `schemaName` property until drizzle patches an issue
28 lines
565 B
TypeScript
28 lines
565 B
TypeScript
import { and, eq } from 'drizzle-orm'
|
|
|
|
import type { DrizzleAdapter, DrizzleTransaction } from '../types.js'
|
|
|
|
type Args = {
|
|
adapter: DrizzleAdapter
|
|
db: DrizzleAdapter['drizzle'] | DrizzleTransaction
|
|
parentID: unknown
|
|
tableName: string
|
|
}
|
|
|
|
export const deleteExistingArrayRows = async ({
|
|
adapter,
|
|
db,
|
|
parentID,
|
|
tableName,
|
|
}: Args): Promise<void> => {
|
|
const table = adapter.tables[tableName]
|
|
|
|
const whereConstraints = [eq(table._parentID, parentID)]
|
|
|
|
await adapter.deleteWhere({
|
|
db,
|
|
tableName,
|
|
where: and(...whereConstraints),
|
|
})
|
|
}
|