Skip to content

Support for Postgres and MySQL via Hyperdrive #6

@imjlk

Description

@imjlk

Since this project is already integrated with Drizzle ORM, I believe we can easily extend its database support. By utilizing Hyperdrive, we can add compatibility for not only Cloudflare D1 but also for Postgres and MySQL.

/**
 * Generic Drizzle database configuration (internal)
 */
interface DrizzleConfig<Fn extends (...args: any) => any> {
     /** Drizzle database instance */
     db: ReturnType<Fn>;
     /** Adapter options (provider omitted) */
     options?: Omit<DrizzleAdapterConfig, "provider">;
}

export interface WithCloudflareOptions extends CloudflarePluginOptions {
    /**
     * D1 database for primary storage, if that's what you're using.
     */
    d1?: DrizzleConfig<typeof d1Drizzle>;

    /** Postgres database configuration for Hyperdrive */
    postgres?: DrizzleConfig<typeof postgresDrizzle>;

    /** MySQL database configuration for Hyperdrive */
    mysql?: DrizzleConfig<typeof mysqlDrizzle>;

    /** KV namespace for secondary storage */
    kv?: KVNamespace<string>;
}

I will open a PR for this shortly. Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions