Class

Repository

Repository()

Constructor

# new Repository()

The Repository class extends BaseRepository to provide additional validation functionality. It overrides prefix methods to perform model validation before database operations and throws ValidationError when validation fails.

Concrete repository implementation with validation support.

View Source repository/Repository.ts, line 8

Example
class UserModel extends Model {
  

Methods

# async protected createAllPrefix(models, args) → {Promise.<Array.<any>>}

Overrides the base createAllPrefix method to add validation checks for multiple models. Creates a context, instantiates new models, enforces decorators, and validates each model before allowing creation to proceed. Collects validation errors from all models.

Prepares multiple models for creation with validation.

Parameters:
Name Type Description
models Array.<M>

The array of model instances to prepare for creation

args Array.<any>

Additional arguments for the create operation

View Source repository/Repository.ts, line 210

If any model fails validation, with details about which models failed

A promise that resolves to an array containing the validated models and context arguments

Promise.<Array.<any>>

# async protected createPrefix(model, args)

Overrides the base createPrefix method to add validation checks. Creates a context, instantiates a new model, enforces decorators, and validates the model before allowing creation to proceed.

Prepares a model for creation with validation.

Parameters:
Name Type Description
model M

The model instance to prepare for creation

args Array.<any>

Additional arguments for the create operation

View Source repository/Repository.ts, line 196

If the model fails validation

A promise that resolves to an array containing the validated model and context arguments

# async protected updateAllPrefix(models, args)

Overrides the base updateAllPrefix method to add validation checks for multiple models. Creates a context, validates primary keys, retrieves existing models, merges old and new models, enforces decorators, and validates each model before allowing updates to proceed. Collects validation errors from all models.

Prepares multiple models for update with validation.

Parameters:
Name Type Description
models Array.<M>

The array of model instances to prepare for update

args Array.<any>

Additional arguments for the update operation

View Source repository/Repository.ts, line 242

If any model doesn't have a primary key value

If any model fails validation, with details about which models failed

A promise that resolves to an array containing the validated models and context arguments

# async protected updatePrefix(model, args)

Overrides the base updatePrefix method to add validation checks. Creates a context, validates the primary key, retrieves the existing model, merges the old and new models, enforces decorators, and validates the model before allowing the update to proceed.

Prepares a model for update with validation.

Parameters:
Name Type Description
model M

The model instance to prepare for update

args Array.<any>

Additional arguments for the update operation

View Source repository/Repository.ts, line 226

If the model doesn't have a primary key value

If the model fails validation

A promise that resolves to an array containing the validated model and context arguments

# static key(key) → {string}

Generates a key for storing metadata in the reflection system by prefixing the provided key with the database reflection prefix.

Creates a reflection key for database operations.

Parameters:
Name Type Description
key string

The base key to prefix

View Source repository/Repository.ts, line 251

The prefixed reflection key

string