Files
payload/packages/db-postgres/src/upsertRow/deleteExistingArrayRows.ts
2023-08-26 22:56:32 -04:00

27 lines
483 B
TypeScript

import { and, eq } from 'drizzle-orm';
import { PostgresAdapter } from '../types';
type Args = {
adapter: PostgresAdapter
parentID: unknown
tableName: string
}
export const deleteExistingArrayRows = async ({
adapter,
parentID,
tableName,
}: Args): Promise<void> => {
const table = adapter.tables[tableName];
const whereConstraints = [
eq(table._parentID, parentID),
];
await adapter.db.delete(table)
.where(
and(...whereConstraints),
);
};