Installation
npm install
@surrealorm/ormnpm install
@surrealorm/ormQuick Start
TypeScript
import { Entity, BaseEntity, Property, SurrealORM } from '@surrealorm/orm';
// Define your entity
@Entity()
class User extends BaseEntity {
@Property({ unique: true })
email!: string;
@Property()
name!: string;
@Property()
age!: number;
}
// Connect to SurrealDB
const orm = new SurrealORM({
url: 'http://localhost:8000',
namespace: 'test',
database: 'test',
username: 'root',
password: 'root'
});
// Specify the type of connection or leave blank for root user
await orm.connect("namespace");
// Create a new user
const user = new User();
user.email = 'john@example.com';
user.name = 'John Doe';
user.age = 30;
await orm.create(user);
// Disconnect from SurrealDB
await orm.disconnect();
import { Entity, BaseEntity, Property, SurrealORM } from '@surrealorm/orm';
// Define your entity
@Entity()
class User extends BaseEntity {
@Property({ unique: true })
email!: string;
@Property()
name!: string;
@Property()
age!: number;
}
// Connect to SurrealDB
const orm = new SurrealORM({
url: 'http://localhost:8000',
namespace: 'test',
database: 'test',
username: 'root',
password: 'root'
});
// Specify the type of connection or leave blank for root user
await orm.connect("namespace");
// Create a new user
const user = new User();
user.email = 'john@example.com';
user.name = 'John Doe';
user.age = 30;
await orm.create(user);
// Disconnect from SurrealDB
await orm.disconnect();
Quick Links
© 2025 SurrealORM. All rights reserved.