### 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, for example,

    function Foo(x) {
      if (!(this instanceof Foo)) { return new Foo(x); }
      this.x = x;
    }

### 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, 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` |  | 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, 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` |  | 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, 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` |  | 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

### 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: model

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

Decorator for model definitions

Parameters

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

### Enumeration: RelationType

Members

Name | Default Value | Flags | Description
--- | --- | --- | ---
belongsTo | "belongsTo" | exported |
embedsMany | "embedsMany" | exported |
embedsOne | "embedsOne" | exported |
hasMany | "hasMany" | exported |
hasOne | "hasOne" | exported |
referencesMany | "referencesMany" | exported |
referencesOne | "referencesOne" | exported |

### Interface: BelongsToDefinition

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
keyFrom | `string` |  | exported |
keyTo | `undefined | string` |  | exported optional |
type | `belongsTo` |  | exported |

### Interface: HasManyDefinition

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
keyTo | `undefined | string` |  | exported optional | The foreign key used by the target model. E.g. when a Customer has many Order instances, then keyTo is "customerId". Note that "customerId" is the default FK assumed by the framework, users can provide a custom FK name by setting "keyTo".
type | `hasMany` |  | exported |

### Interface: RelationDefinitionBase

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
name | `string` |  | exported | The relation name, typically matching the name of the accessor property defined on the source model. For example "orders" or "customer".
source | `Entity` |  | exported | The source model of this relation. E.g. when a Customer has many Order instances, then Customer is the source.
target | `TypeResolver<Entity, Entity>` |  | exported | The target model of this relation. E.g. when a Customer has many Order instances, then Order is the target.
type | `RelationType` |  | exported | The type of the relation, must be one of RelationType values.

### const RELATIONS_KEY = "loopback:relations"

### Function: belongsTo

#### belongsTo(targetResolver: EntityResolver<T>, definition: Partial<BelongsToDefinition>) : (Anonymous function)

Decorator for belongsTo

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
targetResolver | `EntityResolver<T>` |  |  |
definition | `Partial<BelongsToDefinition>` |  | optional |

### Function: embedsMany

#### embedsMany(definition: Object) : anonymous

Decorator for embedsMany

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
definition | `Object` |  | optional |

### Function: embedsOne

#### embedsOne(definition: Object) : anonymous

Decorator for embedsOne

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
definition | `Object` |  | optional |

### Function: getModelRelations

#### getModelRelations(modelCtor: Model) : RelationDefinitionMap

Get metadata of all relations defined on a given model class.

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
modelCtor | `Model` |  |  | The model class (the constructor function).

### Function: hasMany

#### hasMany(targetResolver: EntityResolver<T>, definition: Partial<HasManyDefinition>) : (Anonymous function)

Decorator for hasMany Calls property.array decorator underneath the hood and infers foreign key name from target model name unless explicitly specified

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
targetResolver | `EntityResolver<T>` |  |  | Target model for hasMany relation
definition | `Partial<HasManyDefinition>` |  | optional | Optional metadata for setting up hasMany relation

### Function: hasOne

#### hasOne(definition: Object) : anonymous

Decorator for hasOne

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
definition | `Object` |  | optional |

### Function: referencesMany

#### referencesMany(definition: Object) : anonymous

Decorator for referencesMany

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
definition | `Object` |  | optional |

### Function: referencesOne

#### referencesOne(definition: Object) : anonymous

Decorator for referencesOne

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
definition | `Object` |  | optional |

### Function: relation

#### relation(definition: Object) : anonymous

Decorator for relations

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
definition | `Object` |  | 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>) : void

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.

    export class ProductComponent {
      controllers = [ProductController];
      repositories = [ProductRepo, UserRepo];
      providers = {
        [AUTHENTICATION_STRATEGY]: AuthStrategy,
        [AUTHORIZATION_ROLE]: Role,
      };
    };

    app.component(ProductComponent);

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

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

    const ds: juggler.DataSource = new juggler.DataSource({
      name: 'db',
      connector: 'memory',
    });

    app.dataSource(ds);
    // The datasource can be injected with
    constructor(@inject('datasources.db') dataSource: DataSourceType) {
    }

#### 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

#### 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>>) : void

Add a repository to this application.

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---

repo

`Class<Repository<any>>`

The repository to add.

    class NoteRepo {
      model: any;

      constructor() {
        const ds: juggler.DataSource = new juggler.DataSource({
          name: 'db',
          connector: 'memory',
        });
    <span class="hljs-keyword">this</span>.model = ds.createModel(
      <span class="hljs-string">'note'</span>,
      {title: <span class="hljs-string">'string'</span>, content: <span class="hljs-string">'string'</span>},
      {}
    );  }
    };
    app.repository(NoteRepo);

### Interface: ApplicationWithRepositories

Interface for an Application mixed in with RepositoryMixin

Properties

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

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

Parameters

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

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

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
dataSource | `Class<DataSource> | DataSource` |  |  | 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

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

Parameters

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

#### repository(repo: Class<any>) : void

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
repo | `Class<any>` |  |  | 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.

    class MyApplication extends RepositoryMixin(Application) {}

Please note: the members in the mixin function are documented in a dummy class called RepositoryMixinDoc

Parameters

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

### Class: entity = new Entity()

Base class for entities which have unique ids

#### modelName() : string

#### 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() : string

#### 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` |  |  | Definition for a model
definitionOrType | `PropertyDefinition | PropertyType` |  |  | Definition for a model

#### 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. For example,

    {
      settings: {
        id: ['id']
      }
      properties: {
        id: {
          type: 'string',
          id: true
        }
      }
    }

### 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() : string

### 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 | `undefined | false | true` |  | 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
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` |

### Enumeration: Operators

Operators for where clauses

Members

Name | Default Value | Flags | Description
--- | --- | --- | ---
and |  | exported | Operators for where clauses
between |  | exported | Operators for where clauses
eq |  | exported | Operators for where clauses
exists |  | exported | Operators for where clauses
gt |  | exported | Operators for where clauses
gte |  | exported | Operators for where clauses
inq |  | exported | Operators for where clauses
lt |  | exported | Operators for where clauses
lte |  | exported | Operators for where clauses
neq |  | exported | Operators for where clauses
or |  | exported | Operators for where clauses

### 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` |  | exported | A builder for Filter. It provides fleunt APIs to add clauses such as `fields`, `order`, `where`, `limit`, `offset`, and `include`.

#### constructor(f: Filter) : FilterBuilder

Parameters

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

#### build() : Filter

Return the filter object

#### fields(f: (string | string[] | Fields)[]) : this

Describe what fields to be included/excluded

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
f | `(string | string[] | Fields)[]` |  | 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 | Where) : 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 | Where` |  |  | a constraint object to merge with own filter object

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

Declare `include`

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
i | `(string | string[] | Inclusion)[]` |  | 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[] | Order)[]) : this

Describe the sorting order

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
o | `(string | string[] | Order)[]` |  | rest | A builder for Filter. It provides fleunt APIs to add clauses such as `fields`, `order`, `where`, `limit`, `offset`, and `include`.

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

Alias to `offset`

Parameters

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

#### where(w: Where) : this

Declare a where clause

Parameters

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

### Class: wherebuilder = new WhereBuilder()

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

Properties

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

#### constructor(w: Where) : WhereBuilder

Parameters

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

#### and(w: (Where | Where[])[]) : this

Add an `and` clause.

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
w | `(Where | Where[])[]` |  | rest | One or more where objects

#### between(key: string, val1: any, val2: any) : this

Add a `between` condition

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
key | `string` |  |  | Property name
val1 | `any` |  |  | Property value lower bound
val2 | `any` |  |  | Property value upper bound

#### build() : Where

Get the where object

#### eq(key: string, val: any) : this

Add an `=` condition

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
key | `string` |  |  | Property name
val | `any` |  |  | Property value

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

Add a `exists` condition

Parameters

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

#### gt(key: string, val: any) : this

Add a `>` condition

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
key | `string` |  |  | Property name
val | `any` |  |  | Property value

#### gte(key: string, val: any) : this

Add a `>=` condition

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
key | `string` |  |  | Property name
val | `any` |  |  | Property value

#### impose(where: Where) : 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` |  |  | Where filter

#### inq(key: string, val: any[]) : this

Add a `inq` condition

Parameters

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

#### lt(key: string, val: any) : this

Add a `<` condition

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
key | `string` |  |  | Property name
val | `any` |  |  | Property value

#### lte(key: string, val: any) : this

Add a `<=` condition

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
key | `string` |  |  | Property name
val | `any` |  |  | Property value

#### neq(key: string, val: any) : this

Add a `!=` condition

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
key | `string` |  |  | Property name
val | `any` |  |  | Property value

#### or(w: (Where | Where[])[]) : this

Add an `or` clause.

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
w | `(Where | Where[])[]` |  | rest | One or more where objects

### Interface: Condition

Matching condition

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
and | `Where[]` |  | exported optional | Matching condition
between | `any[]` |  | exported optional | Matching condition
eq | `any` |  | exported optional | Matching condition
exists | `undefined | false | true` |  | exported optional | Matching condition
gt | `any` |  | exported optional | Matching condition
gte | `any` |  | exported optional | Matching condition
inq | `any[]` |  | exported optional | Matching condition
lt | `any` |  | exported optional | Matching condition
lte | `any` |  | exported optional | Matching condition
neq | `any` |  | exported optional | Matching condition
or | `Where[]` |  | exported optional | Matching condition

### Interface: Fields

Selection of fields

Example: `{afieldname: true}`

### Interface: Filter

Query filter object

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
fields | `Fields` |  | exported optional | To include/exclude fields
include | `Inclusion[]` |  | 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` |  | 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` |  | exported optional | Inclusion of related items Note: scope means filter on related items Example: `{relation: 'aRelationName', scope: {<AFilterObject>}}`

### Interface: Order

Order by

Example: `{afieldname: 'ASC'}`

### Interface: Where

Where object

Examples: `{afieldname: 'aName'}` `{and: [{fieldone: 'one'}, {fieldtwo: 'two'}]}` `{or: [{fieldone: 'one'}, {fieldtwo: 'two'}]}`

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
and | `Where[]` |  | exported optional | Where object Examples: `{afieldname: 'aName'}` `{and: [{fieldone: 'one'}, {fieldtwo: 'two'}]}` `{or: [{fieldone: 'one'}, {fieldtwo: 'two'}]}`
or | `Where[]` |  | exported optional | Where object Examples: `{afieldname: 'aName'}` `{and: [{fieldone: 'one'}, {fieldtwo: 'two'}]}` `{or: [{fieldone: 'one'}, {fieldtwo: 'two'}]}`

### Function: filterTemplate

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

Parameters

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

### Function: isFilter

#### isFilter(arg: any) : boolean

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
arg | `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: Partial<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 | `Partial<T>` |  |  | the constraint which is to be applied on the data objects

### Function: constrainFilter

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

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 | 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 | undefined, constraint: AnyObject) : Where

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 | undefined` |  |  | the where filter to apply the constrain(s) to
constraint | `AnyObject` |  |  | 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` |  |  | Key/Value operations for connector implementations
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` |  | constructorProperty exported public | Legacy data source
entityClass | `` |  | constructorProperty exported public | Default implementation of CRUD repository using legacy juggler model and data source
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 | `` |  |  | Constructor of DefaultCrudRepository
dataSource | `DataSource` |  |  | Legacy data source

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

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
where | `Where` |  | 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, options: Options) : Promise<Count>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
where | `Where` |  | 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, options: Options) : Promise<T[]>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
filter | `Filter` |  | 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, 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` |  | 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, options: Options) : Promise<T | null>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
filter | `Filter` |  | 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, 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` |  | 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

### Type alias: BelongsToAccessor(sourceId: SourceId): Promise<Target>

Arguments

Name | Type | Description
--- | --- | ---
sourceId | `SourceId` |

### Type alias: HasManyRepositoryFactory(fkValue: ForeignKeyType): HasManyRepository

Arguments

Name | Type | Description
--- | --- | ---
fkValue | `ForeignKeyType` |

### Function: createBelongsToAccessor

#### createBelongsToAccessor(belongsToMetadata: BelongsToDefinition, targetRepoGetter: Getter<EntityCrudRepository<Target, TargetId>>, sourceRepository: EntityCrudRepository<Source, SourceId>) : BelongsToAccessor<Target, SourceId>

Enforces a BelongsTo constraint on a repository

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
belongsToMetadata | `BelongsToDefinition` |  |  |
targetRepoGetter | `Getter<EntityCrudRepository<Target, TargetId>>` |  |  |
sourceRepository | `EntityCrudRepository<Source, SourceId>` |  |  |

### Function: createHasManyRepositoryFactory

#### createHasManyRepositoryFactory(relationMetadata: HasManyDefinition, targetRepositoryGetter: Getter<EntityCrudRepository<Target, TargetID>>) : HasManyRepositoryFactory<Target, ForeignKeyType>

Enforces a constraint on a repository based on a relationship contract between models. For example, if a Customer model is related to an Order model via a HasMany relation, then, the relational repository returned by the factory function would be constrained by a Customer model instance's id(s).

Returns:

The factory function which accepts a foreign key value to constrain the given target repository

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
relationMetadata | `HasManyDefinition` |  |  |
targetRepositoryGetter | `Getter<EntityCrudRepository<Target, TargetID>>` |  |  |

### Class: defaultbelongstorepository = new DefaultBelongsToRepository()

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
constraint | `DataObject<TargetEntity>` |  | constructorProperty exported public | the key value pair representing foreign key name to constrain the target repository instance
getTargetRepository | `Getter<TargetRepository>` |  | constructorProperty exported public | the getter of the related target model repository instance

#### constructor(getTargetRepository: Getter<TargetRepository>, constraint: DataObject<TargetEntity>) : DefaultBelongsToRepository

Constructor of DefaultBelongsToEntityCrudRepository

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
getTargetRepository | `Getter<TargetRepository>` |  |  | the getter of the related target model repository instance
constraint | `DataObject<TargetEntity>` |  |  | the key value pair representing foreign key name to constrain the target repository instance

#### get(options: Options) : Promise<TargetEntity>

Parameters

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

### Class: defaulthasmanyrepository = new DefaultHasManyRepository()

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
constraint | `DataObject<TargetEntity>` |  | constructorProperty exported public | the key value pair representing foreign key name to constrain the target repository instance
getTargetRepository | `Getter<TargetRepository>` |  | constructorProperty exported public | the getter of the related target model repository instance

#### constructor(getTargetRepository: Getter<TargetRepository>, constraint: DataObject<TargetEntity>) : DefaultHasManyRepository

Constructor of DefaultHasManyEntityCrudRepository

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
getTargetRepository | `Getter<TargetRepository>` |  |  | the getter of the related target model repository instance
constraint | `DataObject<TargetEntity>` |  |  | the key value pair representing foreign key name to constrain the target repository instance

#### create(targetModelData: DataObject<TargetEntity>, options: Options) : Promise<TargetEntity>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
targetModelData | `DataObject<TargetEntity>` |  |  |
options | `Options` |  | optional |

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

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
where | `Where` |  | optional |
options | `Options` |  | optional |

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

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
filter | `Filter` |  | optional |
options | `Options` |  | optional |

#### patch(dataObject: DataObject<TargetEntity>, where: Where, options: Options) : Promise<Count>

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
dataObject | `DataObject<TargetEntity>` |  |  |
where | `Where` |  | optional |
options | `Options` |  | optional |

### Interface: BelongsToRepository

CRUD operations for a target repository of a BelongsTo relation

#### get(options: Options) : Promise<Target>

Gets the target model instance

Parameters

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

### Interface: HasManyRepository

CRUD operations for a target repository of a HasMany relation

#### create(targetModelData: DataObject<Target>, options: Options) : Promise<Target>

Create a target model instance

Returns:

A promise which resolves to the newly created target model instance

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
targetModelData | `DataObject<Target>` |  |  | The target model data
options | `Options` |  | optional | Options for the operation

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

Delete multiple target model instances

Returns:

A promise which resolves the deleted target model instances

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
where | `Where` |  | optional | Instances within the where scope are deleted
options | `Options` |  | optional |

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

Find target model instance(s)

Returns:

A promise which resolves with the found target instance(s)

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
filter | `Filter` |  | optional | CRUD operations for a target repository of a HasMany relation
options | `Options` |  | optional | Options for the operation

#### patch(dataObject: DataObject<Target>, where: Where, options: Options) : Promise<Count>

Patch multiple target model instances

Returns:

A promise which resolves the patched target model instances

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
dataObject | `DataObject<Target>` |  |  | The fields and their new values to patch
where | `Where` |  | optional | Instances within the where scope are patched
options | `Options` |  | optional |

### Class: crudrepositoryimpl = new CrudRepositoryImpl()

Repository implementation

Example:

User can import `CrudRepositoryImpl` and call its functions like: `CrudRepositoryImpl.find(somefilters, someoptions)`

Or extend class `CrudRepositoryImpl` and override its functions:

    export class TestRepository extends CrudRepositoryImpl<Test> {
      constructor(dataSource: DataSource, model: Test) {
        super(dataSource, Customer);
      }

      // Override `deleteAll` to disable the operation
      deleteAll(where?: Where, options?: Options) {
        return Promise.reject(new Error('deleteAll is disabled'));
      }
    }

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---

dataSource

`DataSource`

constructorProperty exported public

Repository implementation

Example:

User can import `CrudRepositoryImpl` and call its functions like: `CrudRepositoryImpl.find(somefilters, someoptions)`

Or extend class `CrudRepositoryImpl` and override its functions:

    export class TestRepository extends CrudRepositoryImpl<Test> {
      constructor(dataSource: DataSource, model: Test) {
        super(dataSource, Customer);
      }

      // Override `deleteAll` to disable the operation
      deleteAll(where?: Where, options?: Options) {
        return Promise.reject(new Error('deleteAll is disabled'));
      }
    }

entityClass

``

constructorProperty exported public

Repository implementation

Example:

User can import `CrudRepositoryImpl` and call its functions like: `CrudRepositoryImpl.find(somefilters, someoptions)`

Or extend class `CrudRepositoryImpl` and override its functions:

    export class TestRepository extends CrudRepositoryImpl<Test> {
      constructor(dataSource: DataSource, model: Test) {
        super(dataSource, Customer);
      }

      // Override `deleteAll` to disable the operation
      deleteAll(where?: Where, options?: Options) {
        return Promise.reject(new Error('deleteAll is disabled'));
      }
    }

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

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---

dataSource

`DataSource`

Repository implementation

Example:

User can import `CrudRepositoryImpl` and call its functions like: `CrudRepositoryImpl.find(somefilters, someoptions)`

Or extend class `CrudRepositoryImpl` and override its functions:

    export class TestRepository extends CrudRepositoryImpl<Test> {
      constructor(dataSource: DataSource, model: Test) {
        super(dataSource, Customer);
      }

      // Override `deleteAll` to disable the operation
      deleteAll(where?: Where, options?: Options) {
        return Promise.reject(new Error('deleteAll is disabled'));
      }
    }

entityClass

``

Repository implementation

Example:

User can import `CrudRepositoryImpl` and call its functions like: `CrudRepositoryImpl.find(somefilters, someoptions)`

Or extend class `CrudRepositoryImpl` and override its functions:

    export class TestRepository extends CrudRepositoryImpl<Test> {
      constructor(dataSource: DataSource, model: Test) {
        super(dataSource, Customer);
      }

      // Override `deleteAll` to disable the operation
      deleteAll(where?: Where, options?: Options) {
        return Promise.reject(new Error('deleteAll is disabled'));
      }
    }

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

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---

where

`Where`

optional

Repository implementation

Example:

User can import `CrudRepositoryImpl` and call its functions like: `CrudRepositoryImpl.find(somefilters, someoptions)`

Or extend class `CrudRepositoryImpl` and override its functions:

    export class TestRepository extends CrudRepositoryImpl<Test> {
      constructor(dataSource: DataSource, model: Test) {
        super(dataSource, Customer);
      }

      // Override `deleteAll` to disable the operation
      deleteAll(where?: Where, options?: Options) {
        return Promise.reject(new Error('deleteAll is disabled'));
      }
    }

options

`Options`

optional

Repository implementation

Example:

User can import `CrudRepositoryImpl` and call its functions like: `CrudRepositoryImpl.find(somefilters, someoptions)`

Or extend class `CrudRepositoryImpl` and override its functions:

    export class TestRepository extends CrudRepositoryImpl<Test> {
      constructor(dataSource: DataSource, model: Test) {
        super(dataSource, Customer);
      }

      // Override `deleteAll` to disable the operation
      deleteAll(where?: Where, options?: Options) {
        return Promise.reject(new Error('deleteAll is disabled'));
      }
    }

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

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---

entity

`DataObject<T>`

Repository implementation

Example:

User can import `CrudRepositoryImpl` and call its functions like: `CrudRepositoryImpl.find(somefilters, someoptions)`

Or extend class `CrudRepositoryImpl` and override its functions:

    export class TestRepository extends CrudRepositoryImpl<Test> {
      constructor(dataSource: DataSource, model: Test) {
        super(dataSource, Customer);
      }

      // Override `deleteAll` to disable the operation
      deleteAll(where?: Where, options?: Options) {
        return Promise.reject(new Error('deleteAll is disabled'));
      }
    }

options

`Options`

optional

Repository implementation

Example:

User can import `CrudRepositoryImpl` and call its functions like: `CrudRepositoryImpl.find(somefilters, someoptions)`

Or extend class `CrudRepositoryImpl` and override its functions:

    export class TestRepository extends CrudRepositoryImpl<Test> {
      constructor(dataSource: DataSource, model: Test) {
        super(dataSource, Customer);
      }

      // Override `deleteAll` to disable the operation
      deleteAll(where?: Where, options?: Options) {
        return Promise.reject(new Error('deleteAll is disabled'));
      }
    }

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

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---

entities

`DataObject<T>[]`

Repository implementation

Example:

User can import `CrudRepositoryImpl` and call its functions like: `CrudRepositoryImpl.find(somefilters, someoptions)`

Or extend class `CrudRepositoryImpl` and override its functions:

    export class TestRepository extends CrudRepositoryImpl<Test> {
      constructor(dataSource: DataSource, model: Test) {
        super(dataSource, Customer);
      }

      // Override `deleteAll` to disable the operation
      deleteAll(where?: Where, options?: Options) {
        return Promise.reject(new Error('deleteAll is disabled'));
      }
    }

options

`Options`

optional

Repository implementation

Example:

User can import `CrudRepositoryImpl` and call its functions like: `CrudRepositoryImpl.find(somefilters, someoptions)`

Or extend class `CrudRepositoryImpl` and override its functions:

    export class TestRepository extends CrudRepositoryImpl<Test> {
      constructor(dataSource: DataSource, model: Test) {
        super(dataSource, Customer);
      }

      // Override `deleteAll` to disable the operation
      deleteAll(where?: Where, options?: Options) {
        return Promise.reject(new Error('deleteAll is disabled'));
      }
    }

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

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---

entity

`DataObject<T>`

Repository implementation

Example:

User can import `CrudRepositoryImpl` and call its functions like: `CrudRepositoryImpl.find(somefilters, someoptions)`

Or extend class `CrudRepositoryImpl` and override its functions:

    export class TestRepository extends CrudRepositoryImpl<Test> {
      constructor(dataSource: DataSource, model: Test) {
        super(dataSource, Customer);
      }

      // Override `deleteAll` to disable the operation
      deleteAll(where?: Where, options?: Options) {
        return Promise.reject(new Error('deleteAll is disabled'));
      }
    }

options

`Options`

optional

Repository implementation

Example:

User can import `CrudRepositoryImpl` and call its functions like: `CrudRepositoryImpl.find(somefilters, someoptions)`

Or extend class `CrudRepositoryImpl` and override its functions:

    export class TestRepository extends CrudRepositoryImpl<Test> {
      constructor(dataSource: DataSource, model: Test) {
        super(dataSource, Customer);
      }

      // Override `deleteAll` to disable the operation
      deleteAll(where?: Where, options?: Options) {
        return Promise.reject(new Error('deleteAll is disabled'));
      }
    }

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

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---

where

`Where`

optional

Repository implementation

Example:

User can import `CrudRepositoryImpl` and call its functions like: `CrudRepositoryImpl.find(somefilters, someoptions)`

Or extend class `CrudRepositoryImpl` and override its functions:

    export class TestRepository extends CrudRepositoryImpl<Test> {
      constructor(dataSource: DataSource, model: Test) {
        super(dataSource, Customer);
      }

      // Override `deleteAll` to disable the operation
      deleteAll(where?: Where, options?: Options) {
        return Promise.reject(new Error('deleteAll is disabled'));
      }
    }

options

`Options`

optional

Repository implementation

Example:

User can import `CrudRepositoryImpl` and call its functions like: `CrudRepositoryImpl.find(somefilters, someoptions)`

Or extend class `CrudRepositoryImpl` and override its functions:

    export class TestRepository extends CrudRepositoryImpl<Test> {
      constructor(dataSource: DataSource, model: Test) {
        super(dataSource, Customer);
      }

      // Override `deleteAll` to disable the operation
      deleteAll(where?: Where, options?: Options) {
        return Promise.reject(new Error('deleteAll is disabled'));
      }
    }

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

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---

id

`ID`

Repository implementation

Example:

User can import `CrudRepositoryImpl` and call its functions like: `CrudRepositoryImpl.find(somefilters, someoptions)`

Or extend class `CrudRepositoryImpl` and override its functions:

    export class TestRepository extends CrudRepositoryImpl<Test> {
      constructor(dataSource: DataSource, model: Test) {
        super(dataSource, Customer);
      }

      // Override `deleteAll` to disable the operation
      deleteAll(where?: Where, options?: Options) {
        return Promise.reject(new Error('deleteAll is disabled'));
      }
    }

options

`Options`

optional

Repository implementation

Example:

User can import `CrudRepositoryImpl` and call its functions like: `CrudRepositoryImpl.find(somefilters, someoptions)`

Or extend class `CrudRepositoryImpl` and override its functions:

    export class TestRepository extends CrudRepositoryImpl<Test> {
      constructor(dataSource: DataSource, model: Test) {
        super(dataSource, Customer);
      }

      // Override `deleteAll` to disable the operation
      deleteAll(where?: Where, options?: Options) {
        return Promise.reject(new Error('deleteAll is disabled'));
      }
    }

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

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---

command

`Command`

Repository implementation

Example:

User can import `CrudRepositoryImpl` and call its functions like: `CrudRepositoryImpl.find(somefilters, someoptions)`

Or extend class `CrudRepositoryImpl` and override its functions:

    export class TestRepository extends CrudRepositoryImpl<Test> {
      constructor(dataSource: DataSource, model: Test) {
        super(dataSource, Customer);
      }

      // Override `deleteAll` to disable the operation
      deleteAll(where?: Where, options?: Options) {
        return Promise.reject(new Error('deleteAll is disabled'));
      }
    }

parameters

`NamedParameters | PositionalParameters`

Repository implementation

Example:

User can import `CrudRepositoryImpl` and call its functions like: `CrudRepositoryImpl.find(somefilters, someoptions)`

Or extend class `CrudRepositoryImpl` and override its functions:

    export class TestRepository extends CrudRepositoryImpl<Test> {
      constructor(dataSource: DataSource, model: Test) {
        super(dataSource, Customer);
      }

      // Override `deleteAll` to disable the operation
      deleteAll(where?: Where, options?: Options) {
        return Promise.reject(new Error('deleteAll is disabled'));
      }
    }

options

`Options`

optional

Repository implementation

Example:

User can import `CrudRepositoryImpl` and call its functions like: `CrudRepositoryImpl.find(somefilters, someoptions)`

Or extend class `CrudRepositoryImpl` and override its functions:

    export class TestRepository extends CrudRepositoryImpl<Test> {
      constructor(dataSource: DataSource, model: Test) {
        super(dataSource, Customer);
      }

      // Override `deleteAll` to disable the operation
      deleteAll(where?: Where, options?: Options) {
        return Promise.reject(new Error('deleteAll is disabled'));
      }
    }

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

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---

id

`ID`

Repository implementation

Example:

User can import `CrudRepositoryImpl` and call its functions like: `CrudRepositoryImpl.find(somefilters, someoptions)`

Or extend class `CrudRepositoryImpl` and override its functions:

    export class TestRepository extends CrudRepositoryImpl<Test> {
      constructor(dataSource: DataSource, model: Test) {
        super(dataSource, Customer);
      }

      // Override `deleteAll` to disable the operation
      deleteAll(where?: Where, options?: Options) {
        return Promise.reject(new Error('deleteAll is disabled'));
      }
    }

options

`Options`

optional

Repository implementation

Example:

User can import `CrudRepositoryImpl` and call its functions like: `CrudRepositoryImpl.find(somefilters, someoptions)`

Or extend class `CrudRepositoryImpl` and override its functions:

    export class TestRepository extends CrudRepositoryImpl<Test> {
      constructor(dataSource: DataSource, model: Test) {
        super(dataSource, Customer);
      }

      // Override `deleteAll` to disable the operation
      deleteAll(where?: Where, options?: Options) {
        return Promise.reject(new Error('deleteAll is disabled'));
      }
    }

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

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---

filter

`Filter`

optional

Repository implementation

Example:

User can import `CrudRepositoryImpl` and call its functions like: `CrudRepositoryImpl.find(somefilters, someoptions)`

Or extend class `CrudRepositoryImpl` and override its functions:

    export class TestRepository extends CrudRepositoryImpl<Test> {
      constructor(dataSource: DataSource, model: Test) {
        super(dataSource, Customer);
      }

      // Override `deleteAll` to disable the operation
      deleteAll(where?: Where, options?: Options) {
        return Promise.reject(new Error('deleteAll is disabled'));
      }
    }

options

`Options`

optional

Repository implementation

Example:

User can import `CrudRepositoryImpl` and call its functions like: `CrudRepositoryImpl.find(somefilters, someoptions)`

Or extend class `CrudRepositoryImpl` and override its functions:

    export class TestRepository extends CrudRepositoryImpl<Test> {
      constructor(dataSource: DataSource, model: Test) {
        super(dataSource, Customer);
      }

      // Override `deleteAll` to disable the operation
      deleteAll(where?: Where, options?: Options) {
        return Promise.reject(new Error('deleteAll is disabled'));
      }
    }

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

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---

id

`ID`

Repository implementation

Example:

User can import `CrudRepositoryImpl` and call its functions like: `CrudRepositoryImpl.find(somefilters, someoptions)`

Or extend class `CrudRepositoryImpl` and override its functions:

    export class TestRepository extends CrudRepositoryImpl<Test> {
      constructor(dataSource: DataSource, model: Test) {
        super(dataSource, Customer);
      }

      // Override `deleteAll` to disable the operation
      deleteAll(where?: Where, options?: Options) {
        return Promise.reject(new Error('deleteAll is disabled'));
      }
    }

filter

`Filter`

optional

Repository implementation

Example:

User can import `CrudRepositoryImpl` and call its functions like: `CrudRepositoryImpl.find(somefilters, someoptions)`

Or extend class `CrudRepositoryImpl` and override its functions:

    export class TestRepository extends CrudRepositoryImpl<Test> {
      constructor(dataSource: DataSource, model: Test) {
        super(dataSource, Customer);
      }

      // Override `deleteAll` to disable the operation
      deleteAll(where?: Where, options?: Options) {
        return Promise.reject(new Error('deleteAll is disabled'));
      }
    }

options

`Options`

optional

Repository implementation

Example:

User can import `CrudRepositoryImpl` and call its functions like: `CrudRepositoryImpl.find(somefilters, someoptions)`

Or extend class `CrudRepositoryImpl` and override its functions:

    export class TestRepository extends CrudRepositoryImpl<Test> {
      constructor(dataSource: DataSource, model: Test) {
        super(dataSource, Customer);
      }

      // Override `deleteAll` to disable the operation
      deleteAll(where?: Where, options?: Options) {
        return Promise.reject(new Error('deleteAll is disabled'));
      }
    }

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

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---

id

`ID`

Repository implementation

Example:

User can import `CrudRepositoryImpl` and call its functions like: `CrudRepositoryImpl.find(somefilters, someoptions)`

Or extend class `CrudRepositoryImpl` and override its functions:

    export class TestRepository extends CrudRepositoryImpl<Test> {
      constructor(dataSource: DataSource, model: Test) {
        super(dataSource, Customer);
      }

      // Override `deleteAll` to disable the operation
      deleteAll(where?: Where, options?: Options) {
        return Promise.reject(new Error('deleteAll is disabled'));
      }
    }

data

`DataObject<T>`

Repository implementation

Example:

User can import `CrudRepositoryImpl` and call its functions like: `CrudRepositoryImpl.find(somefilters, someoptions)`

Or extend class `CrudRepositoryImpl` and override its functions:

    export class TestRepository extends CrudRepositoryImpl<Test> {
      constructor(dataSource: DataSource, model: Test) {
        super(dataSource, Customer);
      }

      // Override `deleteAll` to disable the operation
      deleteAll(where?: Where, options?: Options) {
        return Promise.reject(new Error('deleteAll is disabled'));
      }
    }

options

`Options`

optional

Repository implementation

Example:

User can import `CrudRepositoryImpl` and call its functions like: `CrudRepositoryImpl.find(somefilters, someoptions)`

Or extend class `CrudRepositoryImpl` and override its functions:

    export class TestRepository extends CrudRepositoryImpl<Test> {
      constructor(dataSource: DataSource, model: Test) {
        super(dataSource, Customer);
      }

      // Override `deleteAll` to disable the operation
      deleteAll(where?: Where, options?: Options) {
        return Promise.reject(new Error('deleteAll is disabled'));
      }
    }

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

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---

entity

`DataObject<T>`

Repository implementation

Example:

User can import `CrudRepositoryImpl` and call its functions like: `CrudRepositoryImpl.find(somefilters, someoptions)`

Or extend class `CrudRepositoryImpl` and override its functions:

    export class TestRepository extends CrudRepositoryImpl<Test> {
      constructor(dataSource: DataSource, model: Test) {
        super(dataSource, Customer);
      }

      // Override `deleteAll` to disable the operation
      deleteAll(where?: Where, options?: Options) {
        return Promise.reject(new Error('deleteAll is disabled'));
      }
    }

options

`Options`

optional

Repository implementation

Example:

User can import `CrudRepositoryImpl` and call its functions like: `CrudRepositoryImpl.find(somefilters, someoptions)`

Or extend class `CrudRepositoryImpl` and override its functions:

    export class TestRepository extends CrudRepositoryImpl<Test> {
      constructor(dataSource: DataSource, model: Test) {
        super(dataSource, Customer);
      }

      // Override `deleteAll` to disable the operation
      deleteAll(where?: Where, options?: Options) {
        return Promise.reject(new Error('deleteAll is disabled'));
      }
    }

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

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---

entity

`DataObject<T>`

Repository implementation

Example:

User can import `CrudRepositoryImpl` and call its functions like: `CrudRepositoryImpl.find(somefilters, someoptions)`

Or extend class `CrudRepositoryImpl` and override its functions:

    export class TestRepository extends CrudRepositoryImpl<Test> {
      constructor(dataSource: DataSource, model: Test) {
        super(dataSource, Customer);
      }

      // Override `deleteAll` to disable the operation
      deleteAll(where?: Where, options?: Options) {
        return Promise.reject(new Error('deleteAll is disabled'));
      }
    }

options

`Options`

optional

Repository implementation

Example:

User can import `CrudRepositoryImpl` and call its functions like: `CrudRepositoryImpl.find(somefilters, someoptions)`

Or extend class `CrudRepositoryImpl` and override its functions:

    export class TestRepository extends CrudRepositoryImpl<Test> {
      constructor(dataSource: DataSource, model: Test) {
        super(dataSource, Customer);
      }

      // Override `deleteAll` to disable the operation
      deleteAll(where?: Where, options?: Options) {
        return Promise.reject(new Error('deleteAll is disabled'));
      }
    }

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

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---

data

`DataObject<T>`

Repository implementation

Example:

User can import `CrudRepositoryImpl` and call its functions like: `CrudRepositoryImpl.find(somefilters, someoptions)`

Or extend class `CrudRepositoryImpl` and override its functions:

    export class TestRepository extends CrudRepositoryImpl<Test> {
      constructor(dataSource: DataSource, model: Test) {
        super(dataSource, Customer);
      }

      // Override `deleteAll` to disable the operation
      deleteAll(where?: Where, options?: Options) {
        return Promise.reject(new Error('deleteAll is disabled'));
      }
    }

where

`Where`

optional

Repository implementation

Example:

User can import `CrudRepositoryImpl` and call its functions like: `CrudRepositoryImpl.find(somefilters, someoptions)`

Or extend class `CrudRepositoryImpl` and override its functions:

    export class TestRepository extends CrudRepositoryImpl<Test> {
      constructor(dataSource: DataSource, model: Test) {
        super(dataSource, Customer);
      }

      // Override `deleteAll` to disable the operation
      deleteAll(where?: Where, options?: Options) {
        return Promise.reject(new Error('deleteAll is disabled'));
      }
    }

options

`Options`

optional

Repository implementation

Example:

User can import `CrudRepositoryImpl` and call its functions like: `CrudRepositoryImpl.find(somefilters, someoptions)`

Or extend class `CrudRepositoryImpl` and override its functions:

    export class TestRepository extends CrudRepositoryImpl<Test> {
      constructor(dataSource: DataSource, model: Test) {
        super(dataSource, Customer);
      }

      // Override `deleteAll` to disable the operation
      deleteAll(where?: Where, options?: Options) {
        return Promise.reject(new Error('deleteAll is disabled'));
      }
    }

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

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---

id

`ID`

Repository implementation

Example:

User can import `CrudRepositoryImpl` and call its functions like: `CrudRepositoryImpl.find(somefilters, someoptions)`

Or extend class `CrudRepositoryImpl` and override its functions:

    export class TestRepository extends CrudRepositoryImpl<Test> {
      constructor(dataSource: DataSource, model: Test) {
        super(dataSource, Customer);
      }

      // Override `deleteAll` to disable the operation
      deleteAll(where?: Where, options?: Options) {
        return Promise.reject(new Error('deleteAll is disabled'));
      }
    }

data

`DataObject<T>`

Repository implementation

Example:

User can import `CrudRepositoryImpl` and call its functions like: `CrudRepositoryImpl.find(somefilters, someoptions)`

Or extend class `CrudRepositoryImpl` and override its functions:

    export class TestRepository extends CrudRepositoryImpl<Test> {
      constructor(dataSource: DataSource, model: Test) {
        super(dataSource, Customer);
      }

      // Override `deleteAll` to disable the operation
      deleteAll(where?: Where, options?: Options) {
        return Promise.reject(new Error('deleteAll is disabled'));
      }
    }

options

`Options`

optional

Repository implementation

Example:

User can import `CrudRepositoryImpl` and call its functions like: `CrudRepositoryImpl.find(somefilters, someoptions)`

Or extend class `CrudRepositoryImpl` and override its functions:

    export class TestRepository extends CrudRepositoryImpl<Test> {
      constructor(dataSource: DataSource, model: Test) {
        super(dataSource, Customer);
      }

      // Override `deleteAll` to disable the operation
      deleteAll(where?: Where, options?: Options) {
        return Promise.reject(new Error('deleteAll is disabled'));
      }
    }

### Interface: CrudRepository

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

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

Count matching records

Returns:

A promise of number of records matched

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
where | `Where` |  | 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, options: Options) : Promise<Count>

Delete matching records

Returns:

A promise of number of records deleted

Parameters

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

#### find(filter: Filter, 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` |  | optional | Query filter
options | `Options` |  | optional | Options for the operations

#### updateAll(dataObject: DataObject<T>, where: Where, 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` |  | 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, 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` |  | 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>` |  | constructorProperty exported public | 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>` |  | constructorProperty exported public | 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>` |  | constructorProperty exported public | 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

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>[]` |  | constructorProperty exported public | 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