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;
}

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[]

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

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 if an entity is deleted, otherwise Promise

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

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 if an entity is deleted for the id, otherwise Promise

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 if an entity exists for the id, otherwise Promise

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 if an entity is replaced for the id, otherwise Promise

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 if an entity is updated, otherwise Promise

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

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 if an entity is updated for the id, otherwise Promise

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 if an entry is deleted for the id, otherwise Promise

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 if an entry is configured for the key, otherwise Promise

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 if an entry is set for the key, otherwise Promise

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: Function, definition: Partial<PropertyDefinition>) : (Anonymous function)

Parameters
Name Type Default Value Flags Description
itemType Function

The class of the array to decorate

definition Partial<PropertyDefinition> optional

Optional PropertyDefinition object for additional metadata

Type alias: PropertyMap = MetadataMap

Type alias: RelationMap = MetadataMap

const MODEL_KEY = MetadataAccessor.create< Partial, 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

Class: relationmetadata = new RelationMetadata()

Properties
Name Type Default Value Flags Description
as string exported
target string | Class<Entity> exported
type RelationType exported

Interface: HasManyDefinition

Properties
Name Type Default Value Flags Description
keyTo string exported
type hasMany exported

Interface: RelationDefinitionBase

Properties
Name Type Default Value Flags Description
type RelationType exported

const RELATIONS_KEY = "loopback:relations"

Function: belongsTo

belongsTo(definition: Object) : anonymous

Decorator for belongsTo

Parameters
Name Type Default Value Flags Description
definition Object 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: hasMany

hasMany(targetModel: 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
targetModel 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

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

Function: repository

repository(repositoryName: string | Class<Repository<Model>>) : RepositoryDecorator

Decorator for repository injections on properties or method arguments

class CustomerController {
  @repository(CustomerRepository) public custRepo: CustomerRepository;

  constructor(
    @repository(ProductRepository) public prodRepo: ProductRepository,
  ) {}
  // ...
}

Parameters
Name Type Default Value Flags Description
repositoryName string | Class<Repository<Model>>

Name of the repo

repository(model: string | Entity, dataSource: string | DataSource) : RepositoryDecorator

Decorator for DefaultCrudRepository generation and injection on properties or method arguments based on the given model and dataSource (or their names)

class CustomerController {
  @repository('Customer', 'mySqlDataSource')
  public custRepo: DefaultCrudRepository<
    Customer,
    typeof Customer.prototype.id
  >;

  constructor(
    @repository(Product, mySqlDataSource)
    public prodRepo: DefaultCrudRepository<
      Product,
      typeof Product.prototype.id
    >,
  ) {}
  // ...
}

Parameters
Name Type Default Value Flags Description
model string | Entity

Name/class of the model

dataSource string | DataSource

Name/instance of the dataSource

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') protected 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',
    });

    this.model = ds.createModel(
      'note',
      {title: 'string', content: 'string'},
      {}
    );
  }
};

app.repository(NoteRepo);

Interface: AppWithRepository

Interface for an Application mixed in with RepositoryMixin

Properties
Name Type Default Value Flags Description
options ApplicationConfig exported public optional

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

mountComponentRepository(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

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

modelName string static exported

Base class for models

constructor(data: Partial<Model>) : Model

Parameters
Name Type Default Value Flags Description
data Partial<Model> optional

Base class for models

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

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.

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 undefined | anonymous 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 | true | false 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: PropertyDefinitionMap

Interface: PropertyForm

Properties
Name Type Default Value Flags Description
in undefined | true | false exported optional
name undefined | string exported optional
out undefined | true | false exported optional

Type alias: EntityData = DataObject

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 | true | false) : this

Add a exists condition

Parameters
Name Type Default Value Flags Description
key string

Property name

val undefined | true | false 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 | true | false 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: Partial<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 Partial<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: KVRepository

Key/Value operations for connector implementations

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

Delete an entry by key

Returns:

Promise if an entry is deleted for the key, otherwise Promise

Parameters
Name Type Default Value Flags Description
key string

Key for the entry

options Options optional

Options for the operation

deleteAll(options: Options) : Promise<number>

Delete all entries

Returns:

A promise of the number of entries deleted

Parameters
Name Type Default Value Flags Description
options Options optional

Options for the operation

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

Set up ttl for an entry by key

Returns:

Promise if an entry is set for the key, otherwise Promise

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

iterateKeys(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
filter Filter optional

Filter for keys

options Options optional

Options for the operation

keys(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
options Options optional

Options for the operation

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

Set an entry with key/value

Returns:

Promise if an entry is set for the key, otherwise Promise

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, 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
key string

Key for the entry

ttl number

Key/Value operations for connector implementations

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

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: Partial<T>, options: Options) : Promise<T>

Parameters
Name Type Default Value Flags Description
entity Partial<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: Partial<T>[], options: Options) : Promise<T[]>

Parameters
Name Type Default Value Flags Description
entities Partial<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<boolean>

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

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

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: Partial<T>, 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

data Partial<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 | null>

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

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: Partial<T>, where: Where, options: Options) : Promise<number>

Parameters
Name Type Default Value Flags Description
data Partial<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: Partial<T>, 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

data Partial<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

Type alias: HasManyRepositoryFactory(fkValue: SourceID): HasManyRepository

Arguments
Name Type Description
fkValue SourceID

Function: createHasManyRepositoryFactory

createHasManyRepositoryFactory(relationMetadata: HasManyDefinition, targetRepository: EntityCrudRepository<Target, TargetID>) : HasManyRepositoryFactory<SourceID, Target>

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
targetRepository EntityCrudRepository<Target, TargetID>

Class: defaulthasmanyentitycrudrepository = new DefaultHasManyEntityCrudRepository()

Properties
Name Type Default Value Flags Description
constraint AnyObject constructorProperty exported public

the key value pair representing foreign key name to constrain the target repository instance

targetRepository TargetRepository constructorProperty exported public

the related target model repository instance

constructor(targetRepository: TargetRepository, constraint: AnyObject) : DefaultHasManyEntityCrudRepository

Constructor of DefaultHasManyEntityCrudRepository

Parameters
Name Type Default Value Flags Description
targetRepository TargetRepository

the related target model repository instance

constraint AnyObject

the key value pair representing foreign key name to constrain the target repository instance

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

Parameters
Name Type Default Value Flags Description
targetModelData Partial<TargetEntity>
options Options optional

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

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: Partial<TargetEntity>, where: Where, options: Options) : Promise<number>

Parameters
Name Type Default Value Flags Description
dataObject Partial<TargetEntity>
where Where optional
options Options optional

Interface: HasManyRepository

CRUD operations for a target repository of a HasMany relation

create(targetModelData: Partial<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 Partial<Target>

The target model data

options Options optional

Options for the operation

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

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

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'));
  }
}

model Class<T> 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, model: Class<T>) : 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'));
  }
}

model Class<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'));
  }
}

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

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

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

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<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'));
  }
}

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, 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'));
  }
}

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<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'));
  }
}

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

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

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

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<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'));
  }
}

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

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

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

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

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

Delete an entity

Returns:

Promise if the entity is deleted, otherwise Promise

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

Delete an entity by id

Returns:

Promise if an entity is deleted for the id, otherwise Promise

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 if an entity exists for the id, otherwise Promise

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

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

CRUD operations for a repository of entities

options Options optional

Options for the operations

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

Replace an entity by id

Returns:

Promise if an entity is replaced, otherwise Promise

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

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

Returns:

A promise of an entity saved or null if the entity does not exist

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

Update an entity

Returns:

Promise if the entity is updated, otherwise Promise

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

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

Returns:

Promise if the entity is updated, otherwise Promise

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 | true | false

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