Skip to content

Add synchronous API for in-memory WASM SQLite #86

@krolebord

Description

@krolebord

In memory WASM SQLite supports executing queries synchronously in the main thread, without promises, but currently SQLocal interface expects drivers to be asynchronous

It might be good to have a separate Promise-less SQLocal interface (SQLocalSynchronous or something similar)

export interface SQLocalSynchronous {
    sql: <Result extends Record<string, any>>(queryTemplate: TemplateStringsArray | string, ...params: unknown[]) => Result[];
    batch: <Result extends Record<string, any>>(passStatements: (sql: typeof sqlTag) => Statement[]) => Result[][];
    beginTransaction: () => Transaction;
    transaction: <Result>(transaction: (tx: {
        sql: Transaction["sql"];
        query: Transaction["query"];
    }) => Result) => Result;
    createCallbackFunction: (funcName: string, func: CallbackUserFunction["func"]) => void;
    createScalarFunction: (funcName: string, func: ScalarUserFunction["func"]) => void;
    createAggregateFunction: (funcName: string, func: AggregateUserFunction["func"]) => void;
    getDatabaseInfo: () => DatabaseInfo;
    destroy: () => void;
    [Symbol.dispose]: () => void;
}

I can work on the implementation, if this API makes sense

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