From 7abb2450efc23b664c96cfa12c99da002a1b03fb Mon Sep 17 00:00:00 2001 From: Elliot DeNolf Date: Mon, 2 Oct 2023 17:05:26 -0400 Subject: [PATCH] chore: better typing --- packages/db-postgres/src/create.ts | 9 +++++++-- packages/db-postgres/src/createMigration.ts | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/db-postgres/src/create.ts b/packages/db-postgres/src/create.ts index c01cdc1d2..d330825e5 100644 --- a/packages/db-postgres/src/create.ts +++ b/packages/db-postgres/src/create.ts @@ -2,10 +2,15 @@ import type { Create } from 'payload/database' import toSnakeCase from 'to-snake-case' +import type { PostgresAdapter } from './types' + import { upsertRow } from './upsertRow' -export const create: Create = async function create({ collection: collectionSlug, data, req }) { - const db = this.sessions[req.transactionID]?.db || this.db +export const create: Create = async function create( + this: PostgresAdapter, + { collection: collectionSlug, data, req }, +) { + const db = this.sessions[req.transactionID]?.db || this.drizzle const collection = this.payload.collections[collectionSlug].config const result = await upsertRow({ diff --git a/packages/db-postgres/src/createMigration.ts b/packages/db-postgres/src/createMigration.ts index 0ade66b05..1206a2426 100644 --- a/packages/db-postgres/src/createMigration.ts +++ b/packages/db-postgres/src/createMigration.ts @@ -78,7 +78,7 @@ export const createMigration: CreateMigration = async function createMigration( let drizzleJsonBefore = getDefaultDrizzleSnapshot() - const hasMigrationTable = await migrationTableExists(this.db) + const hasMigrationTable = await migrationTableExists(this.drizzle) if (hasMigrationTable) { const migrationQuery = await payload.find({