Skip to content
🚀 This documentation is for unreal-orm 1.0.0 alpha which requires SurrealDB 2.0 alpha SDK. For the stable version, see npm.

getDatabase

getDatabase(): Promise<SurrealLike>

Defined in: config/index.ts:131

Gets the configured database instance. If a factory was provided, it will be called and the result cached.

Promise<SurrealLike>

The database instance

Error if no database is configured

// In a custom model method
class User extends Table.normal(...) {
async customMethod() {
const db = await getDatabase();
return db.query(surql`SELECT * FROM user WHERE active = true`);
}
}