Skip to content

Providing full DatabaseSync object #2

Description

@FoxxMD

Hello and thanks for making this wonderful library. For me, it's filling the gap for custom migrations drizzle has yet to implement.

In my usecase, I'd like to use iterate to modify rows sequentially without having to hold all results in memory, but SqliteDatabase doesn't expose this.

To get around this I am having to use my DI container to retrieve my DatabaseSync singleton, which works fine in the migration file. But its a lot of complexity that could be avoided if I just had the regular DatabaseSync to begin with, passed to up.

I understand the interface is needed because sqlite-up supports different sqlite providers, but would it be possible to provide the raw db object as an "unsafe" property of the SqliteDatabase object? Basically, I think it would be fine to allow the user to assert the db object they expect like

export const up = async (db: SqliteDatabase): Promise<void> => {
  const nodesq = db.$client as DatabaseSync;
 // or
  if(db.$client instanceof DatabaseSync) { ... }
}

so that they can have full capabilities for the database they are using. Would you consider adding something like this?

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