Skip to content

ambiten


ambiten / core / createSchema

Function: createSchema()

createSchema<T>(schema): AmbitenSchema<T>

Defined in: packages/core/src/utils/builders/schema.ts:23

Creates a new AmbitenSchema instance with the provided schema definition.

Type Parameters

T

T extends Document

The type of the document.

Parameters

schema

SchemaDefinition<T> | Record<keyof T, any>

The schema definition for the document.

Returns

AmbitenSchema<T>

The created AmbitenSchema instance.

Example

ts
const userSchema = createSchema({
  name: { type: String, required: true },
 age: { type: Number, required: true },
 email: { type: String, required: true },
});
const userModel = new AmbitenModel(userSchema, 'users', db);
	
const user = await userModel.create({ name: 'John Doe', age: 30, email: 'example.com' });
console.log(user); // { _id: '...', name: 'John Doe', age: 30, email: 'example.com' }

Context-aware execution infrastructure for multi-tenant systems.