Function isDatabaseOf

  • Type guard for a specialised database adapter. Can be used to use special methods from an adapter on a generic Database object.

    const database = new Database(...); //we don't know the adapter

    if (isDatabaseOf(database, SQLDatabaseAdapter)) {
    // cool, we can use `where(sql)` which is only available for SQLDatabaseAdapter
    database.query(User).where(sql`id > 2`).find();

    //or raw SQL queries
    database.raw(sql`SELECT count(*) FROM ${User}`).find();
    }

    Type Parameters

    Parameters

    • database: Database<any>
    • adapterClassType: AbstractClassType<T>

    Returns database is Database<T>

Generated using TypeDoc