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.

configure

configure(options): void

Defined in: config/index.ts:87

Configures the global database connection for the ORM.

After calling configure(), you can use ORM methods without passing db:

// Before: always pass db
const users = await User.select(db, { limit: 10 });
// After: db is optional
const users = await User.select({ limit: 10 });

ConfigureOptions

Configuration options

void

// Option 1: Pass a pre-connected database
const db = new Surreal();
await db.connect("ws://localhost:8000");
configure({ database: db });
// Option 2: Use a factory function (lazy initialization)
configure({
getDatabase: async () => {
const db = new Surreal();
await db.connect(process.env.SURREAL_URL);
return db;
}
});