Compare commits

...

3 Commits

Author SHA1 Message Date
Sasha
e3ed6ab651 change to web 2025-05-23 19:13:40 +03:00
Sasha
9cc3927d1b temp fix 2025-05-23 18:43:25 +03:00
Sasha
5b4341a568 expose d1 2025-05-23 18:34:06 +03:00
4 changed files with 11 additions and 11 deletions

View File

@@ -1,9 +1,10 @@
import type { DrizzleAdapter } from '@payloadcms/drizzle/types'
import type { Connect, Migration } from 'payload'
import { createClient } from '@libsql/client'
import { createClient } from '@libsql/client/web'
import { pushDevSchema } from '@payloadcms/drizzle'
import { drizzle } from 'drizzle-orm/libsql'
import { drizzle as drizzleD1 } from 'drizzle-orm/d1'
import { drizzle } from 'drizzle-orm/libsql/web'
import type { SQLiteAdapter } from './types.js'
@@ -21,12 +22,14 @@ export const connect: Connect = async function connect(
}
try {
if (!this.client) {
if (!this.client && !this.D1Binding) {
this.client = createClient(this.clientConfig)
}
const logger = this.logger || false
this.drizzle = drizzle(this.client, { logger, schema: this.schema })
this.drizzle = this.D1Binding
? (drizzleD1(this.D1Binding, { logger, schema: this.schema }) as any)
: drizzle(this.client, { logger, schema: this.schema })
if (!hotReload) {
if (process.env.PAYLOAD_DROP_DATABASE === 'true') {

View File

@@ -89,11 +89,10 @@ export function sqliteAdapter(args: Args): DatabaseAdapterObj<SQLiteAdapter> {
allowIDOnCreate,
autoIncrement: args.autoIncrement ?? false,
beforeSchemaInit: args.beforeSchemaInit ?? [],
// @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve
client: undefined,
clientConfig: args.client,
D1Binding: args.D1Binding_Temporary,
defaultDrizzleSnapshot,
// @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve
drizzle: undefined,
features: {
json: true,
@@ -111,7 +110,6 @@ export function sqliteAdapter(args: Args): DatabaseAdapterObj<SQLiteAdapter> {
logger: args.logger,
operators,
prodMigrations: args.prodMigrations,
// @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve
push: args.push,
rawRelations: {},
rawTables: {},
@@ -122,7 +120,6 @@ export function sqliteAdapter(args: Args): DatabaseAdapterObj<SQLiteAdapter> {
sessions: {},
tableNameMap: new Map<string, string>(),
tables: {},
// @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve
transactionOptions: args.transactionOptions || undefined,
updateJobs,
updateMany,
@@ -162,7 +159,6 @@ export function sqliteAdapter(args: Args): DatabaseAdapterObj<SQLiteAdapter> {
find,
findGlobal,
findGlobalVersions,
// @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve
findOne,
findVersions,
indexes: new Set<string>(),
@@ -178,10 +174,8 @@ export function sqliteAdapter(args: Args): DatabaseAdapterObj<SQLiteAdapter> {
packageName: '@payloadcms/db-sqlite',
payload,
queryDrafts,
// @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve
rejectInitializing,
requireDrizzleKit,
// @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve
resolveInitializing,
rollbackTransaction,
updateGlobal,

View File

@@ -51,6 +51,7 @@ export type Args = {
*/
beforeSchemaInit?: SQLiteSchemaHook[]
client: Config
D1Binding_Temporary?: string
/** Generated schema from payload generate:db-schema file path */
generateSchemaOutputFile?: string
idType?: 'number' | 'uuid'
@@ -142,6 +143,7 @@ export type SQLiteAdapter = {
client: Client
clientConfig: Args['client']
countDistinct: CountDistinct
D1Binding?: string
defaultDrizzleSnapshot: any
deleteWhere: DeleteWhere
drizzle: Drizzle

View File

@@ -1,5 +1,6 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {"strictNullChecks": false},
"references": [
{
"path": "../payload"