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.
Returns
Section titled “Returns”Promise<SurrealLike>
The database instance
Throws
Section titled “Throws”Error if no database is configured
Example
Section titled “Example”// In a custom model methodclass User extends Table.normal(...) { async customMethod() { const db = await getDatabase(); return db.query(surql`SELECT * FROM user WHERE active = true`); }}