### Interface: AnyObject

Objects with open properties

### Interface: Class

Interface for classes with `new` operator and static properties/methods

#### constructor(args: any[]) : T

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
args | `any[]` |  | rest | Interface for classes with `new` operator and static properties/methods

### Interface: ConstructorFunction

Interface for constructor functions without `new` operator.

### Interface: Count

Count of Model instances that were successful for methods like `updateAll`, `deleteAll`, etc.

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
count | `number` |  | exported | Count of Model instances that were successful for methods like `updateAll`, `deleteAll`, etc.

### Type alias: Callback(err: Error | string | null | undefined, result: T): void

Type alias for Node.js callback functions

Arguments

Name | Type | Description
--- | --- | ---
err | `Error | string | null | undefined` |
result | `T` |

### Type alias: NamedParameters = AnyObject

### Type alias: Options = AnyObject

### Type alias: PositionalParameters = any[]

### Object literal: CountSchema

JSON Schema describing the Count interface. It's the response type for REST calls to APIs which return Count

Variables

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
type | `string` | "object" | exported | JSON Schema describing the Count interface. It's the response type for REST calls to APIs which return Count

### Interface: Connector

Common properties/operations for connectors

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
configModel | `Model` |  | exported optional | Common properties/operations for connectors
interfaces | `string[]` |  | exported optional | Common properties/operations for connectors
name | `string` |  | exported | Common properties/operations for connectors

#### connect() : Promise<void>

#### disconnect() : Promise<void>

#### execute(command: Command, parameters: NamedParameters | PositionalParameters, options: Options) : Promise<AnyObject>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
command | `Command` |  |  | Common properties/operations for connectors
parameters | `NamedParameters | PositionalParameters` |  |  | Common properties/operations for connectors
options | `Options` |  | optional | Common properties/operations for connectors

#### ping() : Promise<void>

### Interface: CrudConnector

CRUD operations for connector implementations

#### count(modelClass: Class<Entity>, where: Where<Entity>, options: Options) : Promise<Count>

Count matching entities

Returns:

A promise of number of matching entities

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
modelClass | `Class<Entity>` |  |  | The model class
where | `Where<Entity>` |  | optional | The matching criteria
options | `Options` |  | optional | Options for the operation

#### create(modelClass: Class<Entity>, entity: EntityData, options: Options) : Promise<EntityData>

Create a new entity

Returns:

A promise of the entity created

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
modelClass | `Class<Entity>` |  |  | The model class
entity | `EntityData` |  |  | The entity instance or data
options | `Options` |  | optional | Options for the operation

#### createAll(modelClass: Class<Entity>, entities: EntityData[], options: Options) : Promise<EntityData[]>

Create multiple entities

Returns:

A promise of an array of entities created

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
modelClass | `Class<Entity>` |  |  | The model class
entities | `EntityData[]` |  |  | An array of entity instances or data
options | `Options` |  | optional | Options for the operation

#### delete(modelClass: Class<Entity>, entity: EntityData, options: Options) : Promise<boolean>

Delete an entity

Returns:

Promise<true> if an entity is deleted, otherwise Promise<false>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
modelClass | `Class<Entity>` |  |  | The model class
entity | `EntityData` |  |  | The entity instance or data
options | `Options` |  | optional | Options for the operation

#### deleteAll(modelClass: Class<Entity>, where: Where<Entity>, options: Options) : Promise<Count>

Delete matching entities

Returns:

A promise of number of matching entities deleted

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
modelClass | `Class<Entity>` |  |  | The model class
where | `Where<Entity>` |  | optional | The matching criteria
options | `Options` |  | optional | Options for the operation

#### deleteById(modelClass: Class<Entity>, id: IdType, options: Options) : Promise<boolean>

Delete an entity by id

Returns:

Promise<true> if an entity is deleted for the id, otherwise Promise<false>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
modelClass | `Class<Entity>` |  |  | The model class
id | `IdType` |  |  | The entity id value
options | `Options` |  | optional | Options for the operation

#### exists(modelClass: Class<Entity>, id: IdType, options: Options) : Promise<boolean>

Check if an entity exists for the id

Returns:

Promise<true> if an entity exists for the id, otherwise Promise<false>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
modelClass | `Class<Entity>` |  |  | The model class
id | `IdType` |  |  | The entity id value
options | `Options` |  | optional | Options for the operation

#### find(modelClass: Class<Entity>, filter: Filter, options: Options) : Promise<EntityData[]>

Find matching entities by the filter

Returns:

A promise of an array of entities found for the filter

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
modelClass | `Class<Entity>` |  |  | The model class
filter | `Filter` |  | optional | The query filter
options | `Options` |  | optional | Options for the operation

#### findById(modelClass: Class<Entity>, id: IdType, options: Options) : Promise<EntityData>

Find an entity by id

Returns:

A promise of the entity found for the id

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
modelClass | `Class<Entity>` |  |  | The model class
id | `IdType` |  |  | The entity id value
options | `Options` |  | optional | Options for the operation

#### replaceById(modelClass: Class<Entity>, id: IdType, data: EntityData, options: Options) : Promise<boolean>

Replace an entity by id

Returns:

Promise<true> if an entity is replaced for the id, otherwise Promise<false>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
modelClass | `Class<Entity>` |  |  | The model class
id | `IdType` |  |  | The entity id value
data | `EntityData` |  |  | The data attributes to be updated
options | `Options` |  | optional | Options for the operation

#### save(modelClass: Class<Entity>, entity: EntityData, options: Options) : Promise<EntityData>

Save an entity

Returns:

A promise of the entity saved

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
modelClass | `Class<Entity>` |  |  | The model class
entity | `EntityData` |  |  | The entity instance or data
options | `Options` |  | optional | Options for the operation

#### update(modelClass: Class<Entity>, entity: EntityData, options: Options) : Promise<boolean>

Update an entity

Returns:

Promise<true> if an entity is updated, otherwise Promise<false>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
modelClass | `Class<Entity>` |  |  | The model class
entity | `EntityData` |  |  | The entity instance or data
options | `Options` |  | optional | Options for the operation

#### updateAll(modelClass: Class<Entity>, data: EntityData, where: Where<Entity>, options: Options) : Promise<Count>

Update matching entities

Returns:

A promise of number of matching entities deleted

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
modelClass | `Class<Entity>` |  |  | The model class
data | `EntityData` |  |  | The data attributes to be updated
where | `Where<Entity>` |  | optional | The matching criteria
options | `Options` |  | optional | Options for the operation

#### updateById(modelClass: Class<Entity>, id: IdType, data: EntityData, options: Options) : Promise<boolean>

Update an entity by id

Returns:

Promise<true> if an entity is updated for the id, otherwise Promise<false>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
modelClass | `Class<Entity>` |  |  | The model class
id | `IdType` |  |  | The entity id value
data | `EntityData` |  |  | The data attributes to be updated
options | `Options` |  | optional | Options for the operation

### Interface: KVConnector

Key/Value operations for connector implementations

#### delete(modelClass: Class<Entity>, key: string, options: Options) : Promise<boolean>

Delete an entry by key

Returns:

Promise<true> if an entry is deleted for the id, otherwise Promise<false>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
modelClass | `Class<Entity>` |  |  | Model class
key | `string` |  |  | Key for the entry
options | `Options` |  | optional | Options for the operation

#### deleteAll(modelClass: Class<Entity>, options: Options) : Promise<number>

Delete all entries

Returns:

A promise of the number of entries deleted

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
modelClass | `Class<Entity>` |  |  | Model class
options | `Options` |  | optional | Options for the operation

#### expire(modelClass: Class<Entity>, key: string, ttl: number, options: Options) : Promise<boolean>

Set up ttl for an entry by key

Returns:

Promise<true> if an entry is configured for the key, otherwise Promise<false>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
modelClass | `Class<Entity>` |  |  | Model class
key | `string` |  |  | Key for the entry
ttl | `number` |  |  | Key/Value operations for connector implementations
options | `Options` |  | optional | Options for the operation

#### get(modelClass: Class<Entity>, key: string, options: Options) : Promise<T>

Get an entry by key

Returns:

A promise of the entry found for the key

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
modelClass | `Class<Entity>` |  |  | Model class
key | `string` |  |  | Key for the entry
options | `Options` |  | optional | Options for the operation

#### iterateKeys(modelClass: Class<Entity>, filter: Filter, options: Options) : Promise<Iterator<T>>

Get an Iterator for matching keys

Returns:

A promise of an iterator of entries

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
modelClass | `Class<Entity>` |  |  | Model class
filter | `Filter` |  | optional | Matching filter
options | `Options` |  | optional | Options for the operation

#### keys(modelClass: Class<Entity>, options: Options) : Promise<string[]>

Fetch all keys

Returns:

A promise of an array of keys for all entries

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
modelClass | `Class<Entity>` |  |  | Model class
options | `Options` |  | optional | Options for the operation

#### set(modelClass: Class<Entity>, key: string, value: EntityData, options: Options) : Promise<boolean>

Set an entry with key/value

Returns:

Promise<true> if an entry is set for the key, otherwise Promise<false>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
modelClass | `Class<Entity>` |  |  | Model class
key | `string` |  |  | Key for the entry
value | `EntityData` |  |  | Value for the entry
options | `Options` |  | optional | Options for the operation

#### ttl(modelClass: Class<Entity>, key: string, ttl: number, options: Options) : Promise<number>

Get ttl for an entry by key

Returns:

A promise of the TTL value

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
modelClass | `Class<Entity>` |  |  | Model class
key | `string` |  |  | Key for the entry
ttl | `number` |  |  | Time to live in millisenconds
options | `Options` |  | optional | Options for the operation

### Interface: DataSource

DataSource denotes a configured connector

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
connector | `Connector` |  | exported optional | DataSource denotes a configured connector
name | `string` |  | exported | DataSource denotes a configured connector
settings | `AnyObject` |  | exported | DataSource denotes a configured connector

### Interface: SchemaMigrationOptions

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
existingSchema | `|` |  | exported optional | When set to 'drop', schema migration will drop existing tables and recreate them from scratch, removing any existing data along the way. When set to 'alter', schema migration will try to preserve current schema and data, and perform a non-destructive incremental update.
models | `string[]` |  | exported optional | List of model names to migrate. By default, all models are migrated.

### Class: modelmetadatahelper = new ModelMetadataHelper()

#### getModelMetadata(target: Function, options: InspectionOptions) : ModelDefinition | __type

A utility function to simplify retrieving metadata from a target model and its properties.

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
target | `Function` |  |  | The class from which to retrieve metadata.
options | `InspectionOptions` |  | optional | An options object for the MetadataInspector to customize the output of the metadata retrieval functions.

### Namespace: property

### const property.ERR_NO_ARGS = "decorator received less than two parameters"

### const property.ERR_PROP_NOT_ARRAY = "@property.array can only decorate array properties!"

### Function: property.array

#### property.array(itemType: PropertyType, definition: Partial<PropertyDefinition>) : (Anonymous function)

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
itemType | `PropertyType` |  |  | The type of array items. Examples: `number`, `Product`, `() => Order`.
definition | `Partial<PropertyDefinition>` |  | optional | Optional PropertyDefinition object for additional metadata

### Type alias: PropertyMap = MetadataMap

### const MODEL_KEY = MetadataAccessor.create< Partial<ModelDefinitionSyntax>, ClassDecorator >('loopback:model')

### const MODEL_PROPERTIES_KEY = MetadataAccessor.create< PropertyDefinition, PropertyDecorator >('loopback:model-properties')

### const MODEL_WITH_PROPERTIES_KEY = MetadataAccessor.create< ModelDefinition, ClassDecorator >('loopback:model-and-properties')

### Function: buildModelDefinition

#### buildModelDefinition(target: , def: ModelDefinitionSyntax) : ModelDefinition

Build model definition from decorations

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
target | `` |  |  | Target model class
def | `ModelDefinitionSyntax` |  | optional | Model definition spec

### Function: model

#### model(definition: Partial<ModelDefinitionSyntax>) : (Anonymous function)

Decorator for model definitions

Returns:

A class decorator for `model`

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
definition | `Partial<ModelDefinitionSyntax>` |  | optional |

### Namespace: repository

### Function: repository.getter

#### repository.getter(nameOrClass: string | Class<Repository<Model>>) : markParameterOrPropertyAsInjected

Decorator used to inject a Getter for a repository Mainly intended for usage with repository injections on relation repository factory

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
nameOrClass | `string | Class<Repository<Model>>` |  |  | The repository class (ProductRepository) or a string name ('ProductRepository').

### Class: repositorymetadata = new RepositoryMetadata()

Metadata for a repository

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
dataSource | `DataSource | DataSource` |  | exported optional | Instance of the data source
dataSourceName | `undefined | string` |  | exported optional | Name of the data source
modelClass | `undefined | Entity` |  | exported optional | Class of the model
modelName | `undefined | string` |  | exported optional | Name of the model
name | `undefined | string` |  | exported optional | Name of the predefined repository

#### constructor(modelOrRepo: string | Entity, dataSource: string | DataSource | DataSource) : RepositoryMetadata

Constructor for RepositoryMetadata

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
modelOrRepo | `string | Entity` |  |  | Name or class of the model. If the value is a string and `dataSource` is not present, it will treated as the name of a predefined repository

dataSource

`string | DataSource | DataSource`

optional

Name or instance of the data source

For example:

- new RepositoryMetadata(repoName);
- new RepositoryMetadata(modelName, dataSourceName);
- new RepositoryMetadata(modelClass, dataSourceInstance);
- new RepositoryMetadata(modelName, dataSourceInstance);
- new RepositoryMetadata(modelClass, dataSourceName);

### Type alias: RepositoryDecorator(target: Object, key: undefined | string, descriptorOrIndex: TypedPropertyDescriptor<any> | number): void

Type definition for decorators returned by `@repository` decorator factory

Arguments

Name | Type | Description
--- | --- | ---
target | `Object` |
key | `undefined | string` |
descriptorOrIndex | `TypedPropertyDescriptor<any> | number` |

### Class: repositorymixindoc = new RepositoryMixinDoc()

A dummy class created to generate the tsdoc for the members in repository mixin. Please don't use it.

The members are implemented in function RepositoryMixin

#### constructor(args: any[]) : RepositoryMixinDoc

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
args | `any[]` |  | rest | A dummy class created to generate the tsdoc for the members in repository mixin. Please don't use it. The members are implemented in function RepositoryMixin

#### component(component: Class<__type>) : Binding

Add a component to this application. Also mounts all the components repositories.

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
component | `Class<__type>` |  |  | The component to add.

#### dataSource(dataSource: Class<DataSource> | DataSource, name: undefined | string) : Binding

Add the dataSource to this application.

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
dataSource | `Class<DataSource> | DataSource` |  |  | The dataSource to add.
name | `undefined | string` |  | optional | The binding name of the datasource; defaults to dataSource.name

#### getRepository(repo: Class<R>) : Promise<R>

Retrieve the repository instance from the given Repository class

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
repo | `Class<R>` |  |  | The repository class to retrieve the instance of

#### migrateSchema(options: SchemaMigrationOptions) : Promise<void>

Update or recreate the database schema for all repositories.

WARNING: By default, `migrateSchema()` will attempt to preserve data while updating the schema in your target database, but this is not guaranteed to be safe.

Please check the documentation for your specific connector(s) for a detailed breakdown of behaviors for automigrate!

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
options | `SchemaMigrationOptions` |  | optional | Migration options, e.g. whether to update tables preserving data or rebuild everything from scratch.

#### mountComponentRepository(component: Class<__type>) : void

Get an instance of a component and mount all it's repositories. This function is intended to be used internally by component()

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
component | `Class<__type>` |  |  | The component to mount repositories of

#### repository(repo: Class<Repository<any>>) : Binding

Add a repository to this application.

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
repo | `Class<Repository<any>>` |  |  | The repository to add.

### Interface: ApplicationWithRepositories

Interface for an Application mixed in with RepositoryMixin

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
options | `ApplicationConfig` |  | public exported | Interface for an Application mixed in with RepositoryMixin

#### component(component: Class<unknown>, name: undefined | string) : Binding

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
component | `Class<unknown>` |  |  | Interface for an Application mixed in with RepositoryMixin
name | `undefined | string` |  | optional | Interface for an Application mixed in with RepositoryMixin

#### dataSource(dataSource: Class<D> | D, name: undefined | string) : Binding<D>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
dataSource | `Class<D> | D` |  |  | Interface for an Application mixed in with RepositoryMixin
name | `undefined | string` |  | optional | Interface for an Application mixed in with RepositoryMixin

#### getRepository(repo: Class<R>) : Promise<R>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
repo | `Class<R>` |  |  | Interface for an Application mixed in with RepositoryMixin

#### migrateSchema(options: SchemaMigrationOptions) : Promise<void>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
options | `SchemaMigrationOptions` |  | optional | Interface for an Application mixed in with RepositoryMixin

#### mountComponentRepositories(component: Class<unknown>) : void

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
component | `Class<unknown>` |  |  | Interface for an Application mixed in with RepositoryMixin

#### repository(repo: Class<R>, name: undefined | string) : Binding<R>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
repo | `Class<R>` |  |  | Interface for an Application mixed in with RepositoryMixin
name | `undefined | string` |  | optional | Interface for an Application mixed in with RepositoryMixin

### Function: RepositoryMixin

#### RepositoryMixin(superClass: T) :

A mixin class for Application that creates a .repository() function to register a repository automatically. Also overrides component function to allow it to register repositories automatically.

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
superClass | `T` |  |  |

### Class: entity = new Entity()

Base class for entities which have unique ids

#### modelName() :

#### getId() : any

Get the identity value. If the identity is a composite key, returns an object.

#### getIdObject() : Object

Get the identity as an object, such as `{id: 1}` or `{schoolId: 1, studentId: 2}`

#### buildWhereForId(id: any) : any

Build the where object for the given id

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
id | `any` |  |  | The id value

#### getIdOf(entityOrData: AnyObject) : any

Get the identity value for a given entity instance or entity data object.

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
entityOrData | `AnyObject` |  |  | The data object for which to determine the identity value.

### Class: event = new Event()

Domain events

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
source | `any` |  | exported | Domain events
type | `string` |  | exported | Domain events

### Class: model = new Model()

Base class for models

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
definition | `ModelDefinition` |  | static exported | Base class for models

#### constructor(data: DataObject<Model>) : Model

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
data | `DataObject<Model>` |  | optional | Base class for models

#### modelName() :

#### toJSON() : Object

Serialize into a plain JSON object

#### toObject(options: Options) : Object

Convert to a plain object as DTO

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
options | `Options` |  | optional | Base class for models

### Class: modeldefinition = new ModelDefinition()

Definition for a model

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
name | `string` |  | exported | Definition for a model
properties | `anonymous` |  | exported | Definition for a model
relations | `RelationDefinitionMap` |  | exported | Definition for a model
settings | `anonymous` |  | exported | Definition for a model

#### constructor(nameOrDef: string | ModelDefinitionSyntax) : ModelDefinition

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
nameOrDef | `string | ModelDefinitionSyntax` |  |  | Definition for a model

#### addProperty(name: string, definitionOrType: PropertyDefinition | PropertyType) : this

Add a property

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
name | `string` |  |  | Property definition or name (string)
definitionOrType | `PropertyDefinition | PropertyType` |  |  | Definition or property type

#### addRelation(definition: RelationMetadata) : this

Define a new relation.

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
definition | `RelationMetadata` |  |  | The definition of the new relation.

#### addSetting(name: string, value: any) : this

Add a setting

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
name | `string` |  |  | Setting name
value | `any` |  |  | Setting value

#### idProperties() : string[]

Get an array of names of ID properties, which are specified in the model settings or properties with `id` attribute.

### Class: valueobject = new ValueObject()

Base class for value objects - An object that contains attributes but has no conceptual identity. They should be treated as immutable.

#### modelName() :

### Interface: ModelDefinitionSyntax

DSL for building a model definition.

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
name | `string` |  | exported | DSL for building a model definition.
properties | `undefined | anonymous` |  | exported optional | DSL for building a model definition.
relations | `RelationDefinitionMap` |  | exported optional | DSL for building a model definition.
settings | `undefined | anonymous` |  | exported optional | DSL for building a model definition.

### Interface: Persistable

### Interface: PropertyDefinition

Property definition for a model

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
id | `boolean | number` |  | exported optional | Property definition for a model
itemType | `PropertyType` |  | exported optional | Property definition for a model
json | `PropertyForm` |  | exported optional | Property definition for a model
jsonSchema | `undefined | anonymous` |  | exported optional | Property definition for a model
store | `PropertyForm` |  | exported optional | Property definition for a model
type | `PropertyType` |  | exported | Property definition for a model

### Interface: PropertyForm

See https://github.com/strongloop/loopback-datasource-juggler/issues/432

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
in | `undefined | false | true` |  | exported optional | See https://github.com/strongloop/loopback-datasource-juggler/issues/432
name | `undefined | string` |  | exported optional | See https://github.com/strongloop/loopback-datasource-juggler/issues/432
out | `undefined | false | true` |  | exported optional | See https://github.com/strongloop/loopback-datasource-juggler/issues/432

### Type alias: EntityData = DataObject

### Type alias: EntityResolver = TypeResolver

### Type alias: RelationDefinitionMap(relationName: string): RelationMetadata

A key-value map describing model relations. A relation name is used as the key, a relation definition is the value.

Arguments

Name | Type | Description
--- | --- | ---
relationName | `string` |

### Class: filterbuilder = new FilterBuilder()

A builder for Filter. It provides fleunt APIs to add clauses such as `fields`, `order`, `where`, `limit`, `offset`, and `include`.

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
filter | `Filter<MT>` |  | exported | A builder for Filter. It provides fleunt APIs to add clauses such as `fields`, `order`, `where`, `limit`, `offset`, and `include`.

#### constructor(f: Filter<MT>) : FilterBuilder

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
f | `Filter<MT>` |  | optional | A builder for Filter. It provides fleunt APIs to add clauses such as `fields`, `order`, `where`, `limit`, `offset`, and `include`.

#### build() : Filter<MT>

Return the filter object

#### fields(f: (anonymous | keyof MT | keyof MT[])[]) : this

Describe what fields to be included/excluded

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
f | `(anonymous | keyof MT | keyof MT[])[]` |  | rest | A field name to be included, an array of field names to be included, or an Fields object for the inclusion/exclusion

#### impose(constraint: Filter<MT> | Where<MT>) : this

Add a Filter or Where constraint object. If it is a filter object, create an `and` clause for conflicting keys with its where object. For any other properties, throw an error. If it's not a Filter, coerce it to a filter, and carry out the same logic.

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
constraint | `Filter<MT> | Where<MT>` |  |  | a constraint object to merge with own filter object

#### include(i: (string | string[] | Inclusion<MT>)[]) : this

Declare `include`

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
i | `(string | string[] | Inclusion<MT>)[]` |  | rest | A relation name, an array of relation names, or an `Inclusion` object for the relation/scope definitions

#### limit(limit: number) : this

Set `limit`

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
limit | `number` |  |  | Maximum number of records to be returned

#### offset(offset: number) : this

Set `offset`

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
offset | `number` |  |  | Offset of the number of records to be returned

#### order(o: (string | string[] | anonymous)[]) : this

Describe the sorting order

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
o | `(string | string[] | anonymous)[]` |  | rest | A field name with optional direction, an array of field names, or an Order object for the field/direction pairs

#### skip(skip: number) : this

Alias to `offset`

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
skip | `number` |  |  |

#### where(w: Where<MT>) : this

Declare a where clause

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
w | `Where<MT>` |  |  | Where object

### Class: wherebuilder = new WhereBuilder()

A builder for Where object. It provides fluent APIs to add clauses such as `and`, `or`, and other operators.

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
where | `Where<MT>` |  | exported | A builder for Where object. It provides fluent APIs to add clauses such as `and`, `or`, and other operators.

#### constructor(w: Where<MT>) : WhereBuilder

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
w | `Where<MT>` |  | optional | A builder for Where object. It provides fluent APIs to add clauses such as `and`, `or`, and other operators.

#### and(w: (anonymous | AndClause<MT> | OrClause<MT> | (anonymous | AndClause<MT> | OrClause<MT>)[])[]) : this

Add an `and` clause.

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
w | `(anonymous | AndClause<MT> | OrClause<MT> | (anonymous | AndClause<MT> | OrClause<MT>)[])[]` |  | rest | One or more where objects

#### between(key: K, val1: MT[K], val2: MT[K]) : this

Add a `between` condition

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
key | `K` |  |  | Property name
val1 | `MT[K]` |  |  | Property value lower bound
val2 | `MT[K]` |  |  | Property value upper bound

#### build() : anonymous | AndClause<MT> | OrClause<MT>

Get the where object

#### cast(clause: AndClause<MT> | OrClause<MT> | Condition<MT>) : Where<MT>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
clause | `AndClause<MT> | OrClause<MT> | Condition<MT>` |  |  | And/Or/Condition clause

#### eq(key: K, val: MT[K]) : this

Add an `=` condition

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
key | `K` |  |  | Property name
val | `MT[K]` |  |  | Property value

#### exists(key: K, val: undefined | false | true) : this

Add a `exists` condition

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
key | `K` |  |  | Property name
val | `undefined | false | true` |  | optional | Exists or not

#### gt(key: K, val: MT[K]) : this

Add a `>` condition

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
key | `K` |  |  | Property name
val | `MT[K]` |  |  | Property value

#### gte(key: K, val: MT[K]) : this

Add a `>=` condition

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
key | `K` |  |  | Property name
val | `MT[K]` |  |  | Property value

#### impose(where: Where<MT>) : this

Add a where object. For conflicting keys with the existing where object, create an `and` clause.

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
where | `Where<MT>` |  |  | Where filter

#### inq(key: K, val: MT[K][]) : this

Add a `inq` condition

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
key | `K` |  |  | Property name
val | `MT[K][]` |  |  | An array of property values

#### lt(key: K, val: MT[K]) : this

Add a `<` condition

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
key | `K` |  |  | Property name
val | `MT[K]` |  |  | Property value

#### lte(key: K, val: MT[K]) : this

Add a `<=` condition

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
key | `K` |  |  | Property name
val | `MT[K]` |  |  | Property value

#### neq(key: K, val: MT[K]) : this

Add a `!=` condition

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
key | `K` |  |  | Property name
val | `MT[K]` |  |  | Property value

#### nin(key: K, val: MT[K][]) : this

Add a `nin` condition

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
key | `K` |  |  | Property name
val | `MT[K][]` |  |  | An array of property values

#### or(w: (anonymous | AndClause<MT> | OrClause<MT> | (anonymous | AndClause<MT> | OrClause<MT>)[])[]) : this

Add an `or` clause.

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
w | `(anonymous | AndClause<MT> | OrClause<MT> | (anonymous | AndClause<MT> | OrClause<MT>)[])[]` |  | rest | One or more where objects

### Interface: AndClause

And clause

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
and | `Where<MT>[]` |  | exported | And clause

### Interface: Filter

Query filter object

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
fields | `Fields<MT>` |  | exported optional | To include/exclude fields
include | `Inclusion<MT>[]` |  | exported optional | To include related objects
limit | `undefined | number` |  | exported optional | Maximum number of entities
offset | `undefined | number` |  | exported optional | Offset N number of entities. An alias for `skip`
order | `string[]` |  | exported optional | Sorting order for matched entities. Each item should be formatted as `fieldName ASC` or `fieldName DESC`. For example: `['f1 ASC', 'f2 DESC', 'f3 ASC']`. We might want to use `Order` in the future. Keep it as `string[]` for now for compatibility with LoopBack 3.x.
skip | `undefined | number` |  | exported optional | Skip N number of entities
where | `Where<MT>` |  | exported optional | The matching criteria

### Interface: Inclusion

Inclusion of related items

Note: scope means filter on related items

Example: `{relation: 'aRelationName', scope: {<AFilterObject>}}`

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
relation | `string` |  | exported | Inclusion of related items Note: scope means filter on related items Example: `{relation: 'aRelationName', scope: {<AFilterObject>}}`
scope | `Filter<MT>` |  | exported optional | Inclusion of related items Note: scope means filter on related items Example: `{relation: 'aRelationName', scope: {<AFilterObject>}}`

### Interface: OrClause

Or clause

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
or | `Where<MT>[]` |  | exported | Or clause

### Type alias: KeyOf = Exclude

### Function: filterTemplate

#### filterTemplate(strings: TemplateStringsArray, keys: any[]) : filter

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
strings | `TemplateStringsArray` |  |  |
keys | `any[]` |  | rest |

### Function: isFilter

#### isFilter(candidate: any) : boolean

TypeGuard for Filter

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
candidate | `any` |  |  |

### Function: constrainDataObject

#### constrainDataObject(originalData: DataObject<T>, constraint: DataObject<T>) : DataObject<T>

A utility function which takes a model instance data and enforces constraint(s) on it

Returns:

the modified data with the constraint, otherwise the original instance data

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
originalData | `DataObject<T>` |  |  | the model data to apply the constrain(s) to
constraint | `DataObject<T>` |  |  | the constraint which is to be applied on the data object

### Function: constrainDataObjects

#### constrainDataObjects(originalData: DataObject<T>[], constraint: DataObject<T>) : DataObject<T>[]

A utility function which takes an array of model instance data and enforces constraint(s) on it

Returns:

an array of the modified data with the constraint, otherwise the original instance data array

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
originalData | `DataObject<T>[]` |  |  | the array of model data to apply the constrain(s) to
constraint | `DataObject<T>` |  |  | the constraint which is to be applied on the data objects

### Function: constrainFilter

#### constrainFilter(originalFilter: Filter<T> | undefined, constraint: AnyObject) : Filter<T>

A utility function which takes a filter and enforces constraint(s) on it

Returns:

Filter the modified filter with the constraint, otherwise the original filter

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
originalFilter | `Filter<T> | undefined` |  |  | the filter to apply the constrain(s) to
constraint | `AnyObject` |  |  | the constraint which is to be applied on the filter

### Function: constrainWhere

#### constrainWhere(originalWhere: Where<T> | undefined, constraint: Where<T>) : Where<T>

A utility function which takes a where filter and enforces constraint(s) on it

Returns:

Filter the modified filter with the constraint, otherwise the original filter

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
originalWhere | `Where<T> | undefined` |  |  | the where filter to apply the constrain(s) to
constraint | `Where<T>` |  |  | the constraint which is to be applied on the filter

### Interface: KeyValueRepository

Key/Value operations for connector implementations

#### delete(key: string, options: Options) : Promise<void>

Delete an entry by key

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
key | `string` |  |  | Key for the entry
options | `Options` |  | optional | Options for the operation

#### deleteAll(options: Options) : Promise<void>

Delete all entries

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
options | `Options` |  | optional | Options for the operation

#### expire(key: string, ttl: number, options: Options) : Promise<void>

Set up ttl for an entry by key

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
key | `string` |  |  | Key for the entry
ttl | `number` |  |  | Ttl for the entry
options | `Options` |  | optional | Options for the operation

#### get(key: string, options: Options) : Promise<T>

Get an entry by key

Returns:

A promise of the entry

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
key | `string` |  |  | Key for the entry
options | `Options` |  | optional | Options for the operation

#### keys(filter: KeyValueFilter, options: Options) : AsyncIterable<string>

Get an Iterator for matching keys

Returns:

An async iteratable iterator of keys so that the return value can be used with `for-await-of`.

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
filter | `KeyValueFilter` |  | optional | Filter for keys
options | `Options` |  | optional | Options for the operation

#### set(key: string, value: DataObject<T>, options: Options) : Promise<void>

Set an entry with key/value

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
key | `string` |  |  | Key for the entry
value | `DataObject<T>` |  |  | Value for the entry
options | `Options` |  | optional | Options for the operation

#### ttl(key: string, options: Options) : Promise<number>

Get ttl for an entry by key

Returns:

A promise of the TTL value

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
key | `string` |  |  | Key for the entry
options | `Options` |  | optional | Options for the operation

### Namespace: juggler

### Class: defaultcrudrepository = new DefaultCrudRepository()

Default implementation of CRUD repository using legacy juggler model and data source

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
dataSource | `DataSource` |  | public exported constructorProperty | Legacy data source
entityClass | `` |  | public exported constructorProperty | Legacy entity class
modelClass | `juggler.PersistedModelClass` |  | exported | Default implementation of CRUD repository using legacy juggler model and data source

#### constructor(entityClass: , dataSource: DataSource) : DefaultCrudRepository

Constructor of DefaultCrudRepository

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
entityClass | `` |  |  | Legacy entity class
dataSource | `DataSource` |  |  | Legacy data source

#### count(where: Where<T>, options: Options) : Promise<Count>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
where | `Where<T>` |  | optional | Default implementation of CRUD repository using legacy juggler model and data source
options | `Options` |  | optional | Default implementation of CRUD repository using legacy juggler model and data source

#### create(entity: DataObject<T>, options: Options) : Promise<T>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
entity | `DataObject<T>` |  |  | Default implementation of CRUD repository using legacy juggler model and data source
options | `Options` |  | optional | Default implementation of CRUD repository using legacy juggler model and data source

#### createAll(entities: DataObject<T>[], options: Options) : Promise<T[]>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
entities | `DataObject<T>[]` |  |  | Default implementation of CRUD repository using legacy juggler model and data source
options | `Options` |  | optional | Default implementation of CRUD repository using legacy juggler model and data source

#### delete(entity: T, options: Options) : Promise<void>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
entity | `T` |  |  | Default implementation of CRUD repository using legacy juggler model and data source
options | `Options` |  | optional | Default implementation of CRUD repository using legacy juggler model and data source

#### deleteAll(where: Where<T>, options: Options) : Promise<Count>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
where | `Where<T>` |  | optional | Default implementation of CRUD repository using legacy juggler model and data source
options | `Options` |  | optional | Default implementation of CRUD repository using legacy juggler model and data source

#### deleteById(id: ID, options: Options) : Promise<void>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
id | `ID` |  |  | Default implementation of CRUD repository using legacy juggler model and data source
options | `Options` |  | optional | Default implementation of CRUD repository using legacy juggler model and data source

#### execute(command: Command, parameters: NamedParameters | PositionalParameters, options: Options) : Promise<AnyObject>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
command | `Command` |  |  | Default implementation of CRUD repository using legacy juggler model and data source
parameters | `NamedParameters | PositionalParameters` |  |  | Default implementation of CRUD repository using legacy juggler model and data source
options | `Options` |  | optional | Default implementation of CRUD repository using legacy juggler model and data source

#### exists(id: ID, options: Options) : Promise<boolean>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
id | `ID` |  |  | Default implementation of CRUD repository using legacy juggler model and data source
options | `Options` |  | optional | Default implementation of CRUD repository using legacy juggler model and data source

#### find(filter: Filter<T>, options: Options) : Promise<T[]>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
filter | `Filter<T>` |  | optional | Default implementation of CRUD repository using legacy juggler model and data source
options | `Options` |  | optional | Default implementation of CRUD repository using legacy juggler model and data source

#### findById(id: ID, filter: Filter<T>, options: Options) : Promise<T>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
id | `ID` |  |  | Default implementation of CRUD repository using legacy juggler model and data source
filter | `Filter<T>` |  | optional | Default implementation of CRUD repository using legacy juggler model and data source
options | `Options` |  | optional | Default implementation of CRUD repository using legacy juggler model and data source

#### findOne(filter: Filter<T>, options: Options) : Promise<T | null>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
filter | `Filter<T>` |  | optional | Default implementation of CRUD repository using legacy juggler model and data source
options | `Options` |  | optional | Default implementation of CRUD repository using legacy juggler model and data source

#### replaceById(id: ID, data: DataObject<T>, options: Options) : Promise<void>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
id | `ID` |  |  | Default implementation of CRUD repository using legacy juggler model and data source
data | `DataObject<T>` |  |  | Default implementation of CRUD repository using legacy juggler model and data source
options | `Options` |  | optional | Default implementation of CRUD repository using legacy juggler model and data source

#### save(entity: T, options: Options) : Promise<T>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
entity | `T` |  |  | Default implementation of CRUD repository using legacy juggler model and data source
options | `Options` |  | optional | Default implementation of CRUD repository using legacy juggler model and data source

#### update(entity: T, options: Options) : Promise<void>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
entity | `T` |  |  | Default implementation of CRUD repository using legacy juggler model and data source
options | `Options` |  | optional | Default implementation of CRUD repository using legacy juggler model and data source

#### updateAll(data: DataObject<T>, where: Where<T>, options: Options) : Promise<Count>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
data | `DataObject<T>` |  |  | Default implementation of CRUD repository using legacy juggler model and data source
where | `Where<T>` |  | optional | Default implementation of CRUD repository using legacy juggler model and data source
options | `Options` |  | optional | Default implementation of CRUD repository using legacy juggler model and data source

#### updateById(id: ID, data: DataObject<T>, options: Options) : Promise<void>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
id | `ID` |  |  | Default implementation of CRUD repository using legacy juggler model and data source
data | `DataObject<T>` |  |  | Default implementation of CRUD repository using legacy juggler model and data source
options | `Options` |  | optional | Default implementation of CRUD repository using legacy juggler model and data source

### Function: bindModel

#### bindModel(modelClass: T, ds: DataSource) : T

This is a bridge to the legacy DAO class. The function mixes DAO methods into a model class and attach it to a given data source

Returns:

The new model class with DAO (CRUD) operations

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
modelClass | `T` |  |  | Model class
ds | `DataSource` |  |  | Data source

### Function: ensurePromise

#### ensurePromise(p: legacy.PromiseOrVoid<T>) : Promise<T>

Ensure the value is a promise

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
p | `legacy.PromiseOrVoid<T>` |  |  | Promise or void

### Class: crudrepositoryimpl = new CrudRepositoryImpl()

Repository implementation

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
dataSource | `DataSource` |  | public exported constructorProperty | Repository implementation
entityClass | `` |  | public exported constructorProperty | Repository implementation

#### constructor(dataSource: DataSource, entityClass: ) : CrudRepositoryImpl

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
dataSource | `DataSource` |  |  | Repository implementation
entityClass | `` |  |  | Repository implementation

#### count(where: Where<T>, options: Options) : Promise<Count>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
where | `Where<T>` |  | optional | Repository implementation
options | `Options` |  | optional | Repository implementation

#### create(entity: DataObject<T>, options: Options) : Promise<T>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
entity | `DataObject<T>` |  |  | Repository implementation
options | `Options` |  | optional | Repository implementation

#### createAll(entities: DataObject<T>[], options: Options) : Promise<T[]>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
entities | `DataObject<T>[]` |  |  | Repository implementation
options | `Options` |  | optional | Repository implementation

#### delete(entity: DataObject<T>, options: Options) : Promise<void>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
entity | `DataObject<T>` |  |  | Repository implementation
options | `Options` |  | optional | Repository implementation

#### deleteAll(where: Where<T>, options: Options) : Promise<Count>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
where | `Where<T>` |  | optional | Repository implementation
options | `Options` |  | optional | Repository implementation

#### deleteById(id: ID, options: Options) : Promise<void>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
id | `ID` |  |  | Repository implementation
options | `Options` |  | optional | Repository implementation

#### execute(command: Command, parameters: NamedParameters | PositionalParameters, options: Options) : Promise<AnyObject>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
command | `Command` |  |  | Repository implementation
parameters | `NamedParameters | PositionalParameters` |  |  | Repository implementation
options | `Options` |  | optional | Repository implementation

#### exists(id: ID, options: Options) : Promise<boolean>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
id | `ID` |  |  | Repository implementation
options | `Options` |  | optional | Repository implementation

#### find(filter: Filter<T>, options: Options) : Promise<T[]>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
filter | `Filter<T>` |  | optional | Repository implementation
options | `Options` |  | optional | Repository implementation

#### findById(id: ID, filter: Filter<T>, options: Options) : Promise<T>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
id | `ID` |  |  | Repository implementation
filter | `Filter<T>` |  | optional | Repository implementation
options | `Options` |  | optional | Repository implementation

#### replaceById(id: ID, data: DataObject<T>, options: Options) : Promise<void>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
id | `ID` |  |  | Repository implementation
data | `DataObject<T>` |  |  | Repository implementation
options | `Options` |  | optional | Repository implementation

#### save(entity: DataObject<T>, options: Options) : Promise<T>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
entity | `DataObject<T>` |  |  | Repository implementation
options | `Options` |  | optional | Repository implementation

#### update(entity: DataObject<T>, options: Options) : Promise<void>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
entity | `DataObject<T>` |  |  | Repository implementation
options | `Options` |  | optional | Repository implementation

#### updateAll(data: DataObject<T>, where: Where<T>, options: Options) : Promise<Count>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
data | `DataObject<T>` |  |  | Repository implementation
where | `Where<T>` |  | optional | Repository implementation
options | `Options` |  | optional | Repository implementation

#### updateById(id: ID, data: DataObject<T>, options: Options) : Promise<void>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
id | `ID` |  |  | Repository implementation
data | `DataObject<T>` |  |  | Repository implementation
options | `Options` |  | optional | Repository implementation

### Interface: CrudRepository

Basic CRUD operations for ValueObject and Entity. No ID is required.

#### count(where: Where<T>, options: Options) : Promise<Count>

Count matching records

Returns:

A promise of number of records matched

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
where | `Where<T>` |  | optional | Matching criteria
options | `Options` |  | optional | Options for the operations

#### create(dataObject: DataObject<T>, options: Options) : Promise<T>

Create a new record

Returns:

A promise of record created

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
dataObject | `DataObject<T>` |  |  | The data to be created
options | `Options` |  | optional | Options for the operations

#### createAll(dataObjects: DataObject<T>[], options: Options) : Promise<T[]>

Create all records

Returns:

A promise of an array of records created

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
dataObjects | `DataObject<T>[]` |  |  | An array of data to be created
options | `Options` |  | optional | Options for the operations

#### deleteAll(where: Where<T>, options: Options) : Promise<Count>

Delete matching records

Returns:

A promise of number of records deleted

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
where | `Where<T>` |  | optional | Matching criteria
options | `Options` |  | optional | Options for the operations

#### find(filter: Filter<T>, options: Options) : Promise<T[]>

Find matching records

Returns:

A promise of an array of records found

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
filter | `Filter<T>` |  | optional | Query filter
options | `Options` |  | optional | Options for the operations

#### updateAll(dataObject: DataObject<T>, where: Where<T>, options: Options) : Promise<Count>

Updating matching records with attributes from the data object

Returns:

A promise of number of records updated

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
dataObject | `DataObject<T>` |  |  | The data to be updated
where | `Where<T>` |  | optional | Matching criteria
options | `Options` |  | optional | Options for the operations

### Interface: EntityCrudRepository

CRUD operations for a repository of entities

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
entityClass | `` |  | exported | CRUD operations for a repository of entities

#### delete(entity: DataObject<T>, options: Options) : Promise<void>

Delete an entity

Returns:

A promise that will be resolve if the operation succeeded or will be rejected if the entity was not found.

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
entity | `DataObject<T>` |  |  | Entity to be deleted
options | `Options` |  | optional | Options for the operations

#### deleteById(id: ID, options: Options) : Promise<void>

Delete an entity by id

Returns:

A promise that will be resolve if the operation succeeded or will be rejected if the entity was not found.

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
id | `ID` |  |  | Value for the entity id
options | `Options` |  | optional | Options for the operations

#### exists(id: ID, options: Options) : Promise<boolean>

Check if an entity exists for the given id

Returns:

Promise<true> if an entity exists for the id, otherwise Promise<false>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
id | `ID` |  |  | Value for the entity id
options | `Options` |  | optional | Options for the operations

#### findById(id: ID, filter: Filter<T>, options: Options) : Promise<T>

Find an entity by id, return a rejected promise if not found.

Returns:

A promise of an entity found for the id

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
id | `ID` |  |  | Value for the entity id
filter | `Filter<T>` |  | optional | Additional query options. E.g. `filter.include` configures which related models to fetch as part of the database query (or queries).
options | `Options` |  | optional | Options for the operations

#### replaceById(id: ID, data: DataObject<T>, options: Options) : Promise<void>

Replace an entity by id

Returns:

A promise that will be resolve if the operation succeeded or will be rejected if the entity was not found.

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
id | `ID` |  |  | Value for the entity id
data | `DataObject<T>` |  |  | Data attributes to be replaced
options | `Options` |  | optional | Options for the operations

#### save(entity: DataObject<T>, options: Options) : Promise<T>

Save an entity. If no id is present, create a new entity

Returns:

A promise that will be resolve if the operation succeeded or will be rejected if the entity was not found.

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
entity | `DataObject<T>` |  |  | Entity to be saved
options | `Options` |  | optional | Options for the operations

#### update(entity: DataObject<T>, options: Options) : Promise<void>

Update an entity

Returns:

A promise that will be resolve if the operation succeeded or will be rejected if the entity was not found.

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
entity | `DataObject<T>` |  |  | Entity to be updated
options | `Options` |  | optional | Options for the operations

#### updateById(id: ID, data: DataObject<T>, options: Options) : Promise<void>

Update an entity by id with property/value pairs in the data object

Returns:

A promise that will be resolve if the operation succeeded or will be rejected if the entity was not found.

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
id | `ID` |  |  | Value for the entity id
data | `DataObject<T>` |  |  | Data attributes to be updated
options | `Options` |  | optional | Options for the operations

### Interface: EntityRepository

Base interface for a repository of entities

### Interface: ExecutableRepository

#### execute(command: Command, parameters: NamedParameters | PositionalParameters, options: Options) : Promise<AnyObject>

Execute a query with the given parameter object or an array of parameters

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
command | `Command` |  |  | The query string or command object
parameters | `NamedParameters | PositionalParameters` |  |  | The object with name/value pairs or an array of parameter values
options | `Options` |  | optional | Options

### Interface: Repository

### Class: anytype = new AnyType()

Any type

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
name | `` | "any" | exported | Any type

#### coerce(value: any) : any

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `any` |  |  | Any type

#### defaultValue() : any

#### isCoercible(value: any) : boolean

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `any` |  |  | Any type

#### isInstance(value: any) : boolean

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `any` |  |  | Any type

#### serialize(value: any) : any

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `any` |  |  | Any type

### Class: arraytype = new ArrayType()

Array type, such as string[]

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
itemType | `Type<T>` |  | public exported constructorProperty | Array type, such as string[]
name | `` | "array" | exported | Array type, such as string[]

#### constructor(itemType: Type<T>) : ArrayType

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
itemType | `Type<T>` |  |  | Array type, such as string[]

#### coerce(value: any) : any

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `any` |  |  | Array type, such as string[]

#### defaultValue() : Array<T>

#### isCoercible(value: any) : boolean

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `any` |  |  | Array type, such as string[]

#### isInstance(value: any) : boolean

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `any` |  |  | Array type, such as string[]

#### serialize(value: Array<T> | null | undefined) : undefined | null | any[]

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `Array<T> | null | undefined` |  |  | Array type, such as string[]

### Class: booleantype = new BooleanType()

Boolean type

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
name | `` | "boolean" | exported | Boolean type

#### coerce(value: any) : any

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `any` |  |  | Boolean type

#### defaultValue() : boolean

#### isCoercible(value: any) : boolean

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `any` |  |  | Boolean type

#### isInstance(value: any) : boolean

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `any` |  |  | Boolean type

#### serialize(value: boolean | null | undefined) : undefined | null | false | true

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `boolean | null | undefined` |  |  | Boolean type

### Class: buffertype = new BufferType()

Buffer (binary) type

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
name | `` | "buffer" | exported | Buffer (binary) type

#### coerce(value: any, options: Options) : any

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `any` |  |  | Buffer (binary) type
options | `Options` |  | optional | Buffer (binary) type

#### defaultValue() : Buffer

#### isCoercible(value: any) : boolean

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `any` |  |  | Buffer (binary) type

#### isInstance(value: any) : boolean

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `any` |  |  | Buffer (binary) type

#### serialize(value: Buffer | null | undefined, options: Options) : undefined | null | string

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `Buffer | null | undefined` |  |  | Buffer (binary) type
options | `Options` |  | optional | Buffer (binary) type

### Class: datetype = new DateType()

Date type

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
name | `` | "date" | exported | Date type

#### coerce(value: any) : any

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `any` |  |  | Date type

#### defaultValue() : Date

#### isCoercible(value: any) : boolean

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `any` |  |  | Date type

#### isInstance(value: any) : boolean

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `any` |  |  | Date type

#### serialize(value: Date | null | undefined) : undefined | null | string

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `Date | null | undefined` |  |  | Date type

### const ANY = new AnyType()

### const BOOLEAN = new BooleanType()

### const BUFFER = new BufferType()

### const DATE = new DateType()

### const NUMBER = new NumberType()

### const STRING = new StringType()

### Class: modeltype = new ModelType()

Model type

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
modelClass | `Class<T>` |  | public exported constructorProperty | Model type
name | `string` | "model" | exported | Model type

#### constructor(modelClass: Class<T>) : ModelType

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
modelClass | `Class<T>` |  |  | Model type

#### serialize(value: T | null | undefined) : undefined | null | Object

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `T | null | undefined` |  |  | Model type

### Class: numbertype = new NumberType()

Number type

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
name | `` | "number" | exported | Number type

#### coerce(value: any) : any

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `any` |  |  | Number type

#### defaultValue() : number

#### isCoercible(value: any) : boolean

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `any` |  |  | Number type

#### isInstance(value: any) : boolean

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `any` |  |  | Number type

#### serialize(value: number | null | undefined) : undefined | null | number

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `number | null | undefined` |  |  | Number type

### Class: objecttype = new ObjectType()

Object type

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
name | `string` | "object" | exported | Object type
type | `Class<T>` |  | public exported constructorProperty | Object type

#### constructor(type: Class<T>) : ObjectType

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
type | `Class<T>` |  |  | Object type

#### coerce(value: any) : any

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `any` |  |  | Object type

#### defaultValue() : T

#### isCoercible(value: any) : boolean

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `any` |  |  | Object type

#### isInstance(value: any) : boolean

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `any` |  |  | Object type

#### serialize(value: T | null | undefined) : any

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `T | null | undefined` |  |  | Object type

### Class: stringtype = new StringType()

String type

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
name | `` | "string" | exported | String type

#### coerce(value: any) : string

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `any` |  |  | String type

#### defaultValue() : string

#### isCoercible(value: any) : boolean

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `any` |  |  | String type

#### isInstance(value: any) : boolean

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `any` |  |  | String type

#### serialize(value: string | null | undefined) : undefined | null | string

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `string | null | undefined` |  |  | String type

### Interface: Type

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
name | `string` |  | exported | Name of the type

#### coerce(value: any, options: Options) : T | null | undefined

Coerce the value into this type

Returns:

Coerced value of this type

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `any` |  |  | The value to be coerced
options | `Options` |  | optional | Options for coercion

#### defaultValue() : T | null | undefined

Generate the default value for this type

#### isCoercible(value: any, options: Options) : boolean

Check if the given value can be coerced into this type

Returns:

A flag to indicate if the value can be coerced

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `any` |  |  | The value to to be coerced
options | `Options` |  | optional |

#### isInstance(value: any) : boolean

Test if the given value is an instance of this type

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `any` |  |  | The value

#### serialize(value: T | null | undefined, options: Options) : any

Serialize a value into json

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `T | null | undefined` |  |  | The value of this type
options | `Options` |  | optional | Options for serialization

### Class: uniontype = new UnionType()

Union type, such as string | number

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
itemTypes | `Type<any>[]` |  | public exported constructorProperty | Union type, such as string | number
name | `` | "union" | exported | Union type, such as string | number

#### constructor(itemTypes: Type<any>[]) : UnionType

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
itemTypes | `Type<any>[]` |  |  | Union type, such as string | number

#### coerce(value: any) : any

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `any` |  |  | Union type, such as string | number

#### defaultValue() : any

#### isCoercible(value: any) : boolean

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `any` |  |  | Union type, such as string | number

#### isInstance(value: any) : boolean

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `any` |  |  | Union type, such as string | number

#### serialize(value: any) : any

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
value | `any` |  |  | Union type, such as string | number