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 dbconst users = await User.select(db, { limit: 10 });
// After: db is optionalconst users = await User.select({ limit: 10 });Parameters
Section titled “Parameters”options
Section titled “options”Configuration options
Returns
Section titled “Returns”void
Example
Section titled “Example”// Option 1: Pass a pre-connected databaseconst 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; }});