Skip to content

applySchema

applySchema(db, modelClasses, method): Promise<void>

Defined in: schemaGenerator.ts:202

Applies the generated SurrealQL schema to the database by executing DDL statements.

Surreal

The SurrealDB client instance

AnyModelClass[]

Array of model classes (output of Table.normal)

SchemaApplicationMethod = "IF NOT EXISTS"

How to apply the schema (e.g., ‘IF NOT EXISTS’)

Promise<void>

Promise (resolves when schema has been applied)

import { applySchema, Table, Field } from 'unreal-orm';
const User = Table.normal({ ... });
const Post = Table.normal({ ... });
await applySchema(db, [User, Post]);