Interface: AnyObject

Objects with open properties

Interface: Class

Interface for classes with new operator and static properties/methods

constructor(args: undefined) : T

Interface for classes with new operator and static properties/methods

Arguments
Name Type Description
args

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

Callback(err: undefined, result: T): void

Type alias for Node.js callback functions

Arguments
Name Type Description
err
result T

Interface: Connector

Common properties/operations for connectors

Properties
Name Type Description
configModel Model

Common properties/operations for connectors

interfaces

Common properties/operations for connectors

name string

Common properties/operations for connectors

connect() : Promise

disconnect() : Promise

ping() : Promise

Interface: CrudConnector

CRUD operations for connector implementations

count(modelClass: Class, where: Where, options: Options) : Promise

Count matching entities

Returns:

A promise of number of matching entities

Arguments
Name Type Description
modelClass Class

The model class

where Where

The matching criteria

options Options

Options for the operation

create(modelClass: Class, entity: EntityData, options: Options) : Promise

Create a new entity

Returns:

A promise of the entity created

Arguments
Name Type Description
modelClass Class

The model class

entity EntityData

The entity instance or data

options Options

Options for the operation

createAll(modelClass: Class, entities: undefined, options: Options) : Promise

Create multiple entities

Returns:

A promise of an array of entities created

Arguments
Name Type Description
modelClass Class

The model class

entities

An array of entity instances or data

options Options

Options for the operation

delete(modelClass: Class, entity: EntityData, options: Options) : Promise

Delete an entity

Returns:

Promise if an entity is deleted, otherwise Promise

Arguments
Name Type Description
modelClass Class

The model class

entity EntityData

The entity instance or data

options Options

Options for the operation

deleteAll(modelClass: Class, where: Where, options: Options) : Promise

Delete matching entities

Returns:

A promise of number of matching entities deleted

Arguments
Name Type Description
modelClass Class

The model class

where Where

The matching criteria

options Options

Options for the operation

deleteById(modelClass: Class, id: IdType, options: Options) : Promise

Delete an entity by id

Returns:

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

Arguments
Name Type Description
modelClass Class

The model class

id IdType

The entity id value

options Options

Options for the operation

exists(modelClass: Class, id: IdType, options: Options) : Promise

Check if an entity exists for the id

Returns:

Promise if an entity exists for the id, otherwise Promise

Arguments
Name Type Description
modelClass Class

The model class

id IdType

The entity id value

options Options

Options for the operation

find(modelClass: Class, filter: Filter, options: Options) : Promise

Find matching entities by the filter

Returns:

A promise of an array of entities found for the filter

Arguments
Name Type Description
modelClass Class

The model class

filter Filter

The query filter

options Options

Options for the operation

findById(modelClass: Class, id: IdType, options: Options) : Promise

Find an entity by id

Returns:

A promise of the entity found for the id

Arguments
Name Type Description
modelClass Class

The model class

id IdType

The entity id value

options Options

Options for the operation

replaceById(modelClass: Class, id: IdType, data: EntityData, options: Options) : Promise

Replace an entity by id

Returns:

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

Arguments
Name Type Description
modelClass Class

The model class

id IdType

The entity id value

data EntityData

The data attributes to be updated

options Options

Options for the operation

save(modelClass: Class, entity: EntityData, options: Options) : Promise

Save an entity

Returns:

A promise of the entity saved

Arguments
Name Type Description
modelClass Class

The model class

entity EntityData

The entity instance or data

options Options

Options for the operation

update(modelClass: Class, entity: EntityData, options: Options) : Promise

Update an entity

Returns:

Promise if an entity is updated, otherwise Promise

Arguments
Name Type Description
modelClass Class

The model class

entity EntityData

The entity instance or data

options Options

Options for the operation

updateAll(modelClass: Class, data: EntityData, where: Where, options: Options) : Promise

Update matching entities

Returns:

A promise of number of matching entities deleted

Arguments
Name Type Description
modelClass Class

The model class

data EntityData

The data attributes to be updated

where Where

The matching criteria

options Options

Options for the operation

updateById(modelClass: Class, id: IdType, data: EntityData, options: Options) : Promise

Update an entity by id

Returns:

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

Arguments
Name Type Description
modelClass Class

The model class

id IdType

The entity id value

data EntityData

The data attributes to be updated

options Options

Options for the operation

Interface: DataSource

DataSource denotes a configured connector

Properties
Name Type Description
connector Connector

DataSource denotes a configured connector

name string

DataSource denotes a configured connector

settings AnyObject

DataSource denotes a configured connector

model(definition: Object) : (Anonymous function)

Decorator for model definitions

Arguments
Name Type Description
definition Object

property(definition: Object) : (Anonymous function)

Decorator for model properties

Arguments
Name Type Description
definition Object

Class: relationmetadata = new RelationMetadata()

Properties
Name Type Description
as string
target
type RelationType

belongsTo(definition: Object) : (Anonymous function)

Decorator for belongsTo

Arguments
Name Type Description
definition Object

embedsMany(definition: Object) : (Anonymous function)

Decorator for embedsMany

Arguments
Name Type Description
definition Object

embedsOne(definition: Object) : (Anonymous function)

Decorator for embedsOne

Arguments
Name Type Description
definition Object

hasMany(definition: Object) : (Anonymous function)

Decorator for hasMany

Arguments
Name Type Description
definition Object

hasOne(definition: Object) : (Anonymous function)

Decorator for hasOne

Arguments
Name Type Description
definition Object

referencesMany(definition: Object) : (Anonymous function)

Decorator for referencesMany

Arguments
Name Type Description
definition Object

referencesOne(definition: Object) : (Anonymous function)

Decorator for referencesOne

Arguments
Name Type Description
definition Object

relation(definition: Object) : (Anonymous function)

Decorator for relations

Arguments
Name Type Description
definition Object

Class: repositorymetadata = new RepositoryMetadata()

Metadata for a repository

Properties
Name Type Description
dataSource

Instance of the data source

dataSourceName string

Name of the data source

modelClass

Class of the model

modelName string

Name of the model

name string

Name of the predefined repository

constructor(modelOrRepo: undefined, dataSource: undefined) : RepositoryMetadata

Constructor for RepositoryMetadata

Arguments
Name Type Description
modelOrRepo

Constructor for RepositoryMetadata

dataSource

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

repository(model: undefined, dataSource: undefined) : (Anonymous function)

Decorator for model definitions

Returns:

For example:

  • @repository('myCustomerRepo')
  • @repository('Customer', 'mysqlDataSource')
  • @repository(Customer, mysqlDataSource)
  • @repository('Customer', mysqlDataSource)
  • @repository(Customer, 'mysqlDataSource')

Arguments
Name Type Description
model

Name of the repo or name/class of the model

dataSource

Name or instance of the data source

Interface: KVConnector

Key/Value operations for connector implementations

delete(modelClass: Class, key: string, options: Options) : Promise

Delete an entry by key

Returns:

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

Arguments
Name Type Description
modelClass Class

Model class

key string

Key for the entry

options Options

Options for the operation

deleteAll(modelClass: Class, options: Options) : Promise

Delete all entries

Returns:

A promise of the number of entries deleted

Arguments
Name Type Description
modelClass Class

Model class

options Options

Options for the operation

expire(modelClass: Class, key: string, ttl: number, options: Options) : Promise

Set up ttl for an entry by key

Returns:

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

Arguments
Name Type Description
modelClass Class

Model class

key string

Key for the entry

ttl number

Key/Value operations for connector implementations

options Options

Options for the operation

get(modelClass: Class, key: string, options: Options) : Promise

Get an entry by key

Returns:

A promise of the entry found for the key

Arguments
Name Type Description
modelClass Class

Model class

key string

Key for the entry

options Options

Options for the operation

iterateKeys(modelClass: Class, filter: Filter, options: Options) : Promise

Get an Iterator for matching keys

Returns:

A promise of an iterator of entries

Arguments
Name Type Description
modelClass Class

Model class

filter Filter

Matching filter

options Options

Options for the operation

keys(modelClass: Class, options: Options) : Promise

Fetch all keys

Returns:

A promise of an array of keys for all entries

Arguments
Name Type Description
modelClass Class

Model class

options Options

Options for the operation

set(modelClass: Class, key: string, value: EntityData, options: Options) : Promise

Set an entry with key/value

Returns:

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

Arguments
Name Type Description
modelClass Class

Model class

key string

Key for the entry

value EntityData

Value for the entry

options Options

Options for the operation

ttl(modelClass: Class, key: string, ttl: number, options: Options) : Promise

Get ttl for an entry by key

Returns:

A promise of the TTL value

Arguments
Name Type Description
modelClass Class

Model class

key string

Key for the entry

ttl number

Time to live in millisenconds

options Options

Options for the operation

Interface: KVRepository

Key/Value operations for connector implementations

delete(key: string, options: Options) : Promise

Delete an entry by key

Returns:

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

Arguments
Name Type Description
key string

Key for the entry

options Options

Options for the operation

deleteAll(options: Options) : Promise

Delete all entries

Returns:

A promise of the number of entries deleted

Arguments
Name Type Description
options Options

Options for the operation

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

Set up ttl for an entry by key

Returns:

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

Arguments
Name Type Description
key string

Key for the entry

ttl number

Key/Value operations for connector implementations

options Options

Options for the operation

get(key: string, options: Options) : Promise

Get an entry by key

Returns:

A promise of the entry

Arguments
Name Type Description
key string

Key for the entry

options Options

Options for the operation

iterateKeys(filter: Filter, options: Options) : Promise

Get an Iterator for matching keys

Returns:

A promise of an iterator of entries

Arguments
Name Type Description
filter Filter

Filter for keys

options Options

Options for the operation

keys(options: Options) : Promise

Fetch all keys

Returns:

A promise of an array of keys for all entries

Arguments
Name Type Description
options Options

Options for the operation

set(key: string, value: DataObject, options: Options) : Promise

Set an entry with key/value

Returns:

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

Arguments
Name Type Description
key string

Key for the entry

value DataObject

Value for the entry

options Options

Options for the operation

ttl(key: string, ttl: number, options: Options) : Promise

Get ttl for an entry by key

Returns:

A promise of the TTL value

Arguments
Name Type Description
key string

Key for the entry

ttl number

Key/Value operations for connector implementations

options Options

Options for the operation

Class: defaultcrudrepository = new DefaultCrudRepository()

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

Properties
Name Type Description
modelClass PersistedModel

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

constructor(modelClass: PersistedModel, dataSource: DataSource) : DefaultCrudRepository

Constructor of DefaultCrudRepository

Arguments
Name Type Description
modelClass PersistedModel

Legacy model class

dataSource DataSource

Legacy data source

count(where: Where, options: Options) : Promise

Arguments
Name Type Description
where Where

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

options Options

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

create(entity: DataObject, options: Options) : Promise

Arguments
Name Type Description
entity DataObject

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

options Options

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

createAll(entities: undefined, options: Options) : Promise

Arguments
Name Type Description
entities

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

options Options

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

delete(entity: DataObject, options: Options) : Promise

Arguments
Name Type Description
entity DataObject

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

options Options

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

deleteAll(where: Where, options: Options) : Promise

Arguments
Name Type Description
where Where

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

options Options

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

deleteById(id: ID, options: Options) : Promise

Arguments
Name Type Description
id ID

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

options Options

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

exists(id: ID, options: Options) : Promise

Arguments
Name Type Description
id ID

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

options Options

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

find(filter: Filter, options: Options) : Promise

Arguments
Name Type Description
filter Filter

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

options Options

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

findById(id: ID, filter: Filter, options: Options) : Promise

Arguments
Name Type Description
id ID

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

filter Filter

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

options Options

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

replaceById(id: ID, data: DataObject, options: Options) : Promise

Arguments
Name Type Description
id ID

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

data DataObject

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

options Options

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

save(entity: DataObject, options: Options) : Promise

Arguments
Name Type Description
entity DataObject

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

options Options

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

update(entity: DataObject, options: Options) : Promise

Arguments
Name Type Description
entity DataObject

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

options Options

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

updateAll(data: DataObject, where: Where, options: Options) : Promise

Arguments
Name Type Description
data DataObject

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

where Where

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

options Options

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

updateById(id: ID, data: DataObject, options: Options) : Promise

Arguments
Name Type Description
id ID

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

data DataObject

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

options Options

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

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

Arguments
Name Type Description
modelClass T

Model class

ds DataSource

Data source

Class: mixinbuilder = new MixinBuilder()

A builder to compose mixins

Properties
Name Type Description
baseClass Class

The base class

constructor(baseClass: Class) : MixinBuilder

Constructor for MixinBuilder

Arguments
Name Type Description
baseClass Class

The base class

with(mixins: undefined) : Class

Apply one or more mixin functions

Arguments
Name Type Description
mixins

An array of mixin functions

mix(baseClass: Class) : MixinBuilder

Create an instance of MixinBuilder with the base class

Arguments
Name Type Description
baseClass Class

The base class

Interface: MixinFunc

Interface for functions that can mix properties/methods into a base class

For example,

var calculatorMixin = Base => class extends Base {
  calc() { }
};

function timestampMixin(Base) {
  return class extends Base {
    created: Date = new Date();
    modified: Date = new Date();
  }
}

See http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/.

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

Arguments
Name Type Description
id any

The id value

Class: event = new Event()

Domain events

Properties
Name Type Description
source any

Domain events

type string

Domain events

Class: model = new Model()

Base class for models

Properties
Name Type Description
definition ModelDefinition

Base class for models

modelName string

Base class for models

toJSON() : Object

Serialize into a plain JSON object

toObject(options: Options) : Object

Convert to a plain object as DTO

Arguments
Name Type Description
options Options

Base class for models

Class: modeldefinition = new ModelDefinition()

Definition for a model

Properties
Name Type Description
name string

Definition for a model

properties Function

Definition for a model

settings Function

Definition for a model

constructor(name: string, properties, settings) : ModelDefinition

Definition for a model

Arguments
Name Type Description
name string

Definition for a model

properties Function

Definition for a model

settings Function

Definition for a model

addProperty(property: undefined, type: PropertyType) : this

Add a property

Arguments
Name Type Description
property

Property definition or name (string)

type PropertyType

Property type

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

Add a setting

Arguments
Name Type Description
name string

Setting name

value any

Setting value

idProperties() :

Get an array of definitions for 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: propertydefinition = new PropertyDefinition()

Property definition for a model

Properties
Name Type Description
json PropertyForm

Property definition for a model

name string

Property definition for a model

store PropertyForm

Property definition for a model

type PropertyType

Property definition for a model

constructor(name: string, type: PropertyType) : PropertyDefinition

Property definition for a model

Arguments
Name Type Description
name string

Property definition for a model

type PropertyType

Property definition for a model

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

Interface: PropertyForm

Properties
Name Type Description
in boolean
name string
out boolean

EntityData = DataObject

Interface: Condition

Matching condition

Properties
Name Type Description
and

Matching condition

between

Matching condition

eq any

Matching condition

exists boolean

Matching condition

get any

Matching condition

gt any

Matching condition

inq

Matching condition

lt any

Matching condition

lte any

Matching condition

neq any

Matching condition

or

Matching condition

Interface: Fields

Selection of fields

Example: {afieldname: true}

Interface: Filter

Query filter object

Properties
Name Type Description
fields Fields

To include/exclude fields

include

To include related objects

limit number

Maximum number of entities

offset number

Offset N number of entities. An alias for skip

order

Sorting order for matched entities

skip number

Skip N number of entities

where Where

The matching criteria

Interface: Inclusion

Inclusion of related items

Note: scope means filter on related items

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

Properties
Name Type Description
relation string

Inclusion of related items

Note: scope means filter on related items

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

scope Filter

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

Where object

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

or

Where object

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

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

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

Arguments
Name Type 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

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

Arguments
Name Type Description
where Where

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

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

Arguments
Name Type Description
entity DataObject

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

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

Arguments
Name Type Description
entities

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

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

Arguments
Name Type Description
entity DataObject

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

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

Arguments
Name Type Description
where Where

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

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

Arguments
Name Type 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

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

Arguments
Name Type 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

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

Arguments
Name Type Description
filter Filter

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

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

Arguments
Name Type 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

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

Arguments
Name Type 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

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

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

Arguments
Name Type Description
entity DataObject

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

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

Arguments
Name Type Description
entity DataObject

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

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

Arguments
Name Type Description
data DataObject

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

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

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

Arguments
Name Type 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

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

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

Returns:

A promise of number of records matched

Arguments
Name Type Description
where Where

Matching criteria

options Options

Options for the operations

create(dataObject: DataObject, options: Options) : Promise

Create a new record

Returns:

A promise of record created

Arguments
Name Type Description
dataObject DataObject

The data to be created

options Options

Options for the operations

createAll(dataObjects: undefined, options: Options) : Promise

Create all records

Returns:

A promise of an array of records created

Arguments
Name Type Description
dataObjects

An array of data to be created

options Options

Options for the operations

deleteAll(where: Where, options: Options) : Promise

Delete matching records

Returns:

A promise of number of records deleted

Arguments
Name Type Description
where Where

Matching criteria

options Options

Options for the operations

find(filter: Filter, options: Options) : Promise

Find matching records

Returns:

A promise of an array of records found

Arguments
Name Type Description
filter Filter

Query filter

options Options

Options for the operations

updateAll(dataObject: DataObject, where: Where, options: Options) : Promise

Updating matching records with attributes from the data object

Returns:

A promise of number of records updated

Arguments
Name Type Description
dataObject DataObject

The data to be updated

where Where

Matching criteria

options Options

Options for the operations

Interface: EntityCrudRepository

CRUD operations for a repository of entities

delete(entity: DataObject, options: Options) : Promise

Delete an entity

Returns:

Promise if the entity is deleted, otherwise Promise

Arguments
Name Type Description
entity DataObject

Entity to be deleted

options Options

Options for the operations

deleteById(id: ID, options: Options) : Promise

Delete an entity by id

Returns:

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

Arguments
Name Type Description
id ID

Value for the entity id

options Options

Options for the operations

exists(id: ID, options: Options) : Promise

Check if an entity exists for the given id

Returns:

Promise if an entity exists for the id, otherwise Promise

Arguments
Name Type Description
id ID

Value for the entity id

options Options

Options for the operations

findById(id: ID, filter: Filter, options: Options) : Promise

Find an entity by id

Returns:

A promise of an entity found for the id

Arguments
Name Type Description
id ID

Value for the entity id

filter Filter

CRUD operations for a repository of entities

options Options

Options for the operations

replaceById(id: ID, data: DataObject, options: Options) : Promise

Replace an entity by id

Returns:

Promise if an entity is replaced, otherwise Promise

Arguments
Name Type Description
id ID

Value for the entity id

data DataObject

Data attributes to be replaced

options Options

Options for the operations

save(entity: DataObject, options: Options) : Promise

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

Arguments
Name Type Description
entity DataObject

Entity to be saved

options Options

Options for the operations

update(entity: DataObject, options: Options) : Promise

Update an entity

Returns:

Promise if the entity is updated, otherwise Promise

Arguments
Name Type Description
entity DataObject

Entity to be updated

options Options

Options for the operations

updateById(id: ID, data: DataObject, options: Options) : Promise

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

Returns:

Promise if the entity is updated, otherwise Promise

Arguments
Name Type Description
id ID

Value for the entity id

data DataObject

Data attributes to be updated

options Options

Options for the operations

Interface: EntityRepository

Base interface for a repository of entities

Interface: Repository

Class: anytype = new AnyType()

Any type

Properties
Name Type Description
name

Any type

coerce(value: any) : any

Arguments
Name Type Description
value any

Any type

defaultValue() : any

isCoercible(value: any) : boolean

Arguments
Name Type Description
value any

Any type

isInstance(value: any) : boolean

Arguments
Name Type Description
value any

Any type

serialize(value: any) : any

Arguments
Name Type Description
value any

Any type

Class: arraytype = new ArrayType()

Array type, such as string[]

Properties
Name Type Description
itemType Type

Array type, such as string[]

name

Array type, such as string[]

constructor(itemType: Type) : ArrayType

Array type, such as string[]

Arguments
Name Type Description
itemType Type

Array type, such as string[]

coerce(value: any) : any

Arguments
Name Type Description
value any

Array type, such as string[]

defaultValue() : Array

isCoercible(value: any) : boolean

Arguments
Name Type Description
value any

Array type, such as string[]

isInstance(value: any) : boolean

Arguments
Name Type Description
value any

Array type, such as string[]

serialize(value: undefined) :

Arguments
Name Type Description
value

Array type, such as string[]

Class: booleantype = new BooleanType()

Boolean type

Properties
Name Type Description
name

Boolean type

coerce(value: any) : any

Arguments
Name Type Description
value any

Boolean type

defaultValue() : boolean

isCoercible(value: any) : boolean

Arguments
Name Type Description
value any

Boolean type

isInstance(value: any) : boolean

Arguments
Name Type Description
value any

Boolean type

serialize(value: undefined) : boolean

Arguments
Name Type Description
value

Boolean type

Class: buffertype = new BufferType()

Buffer (binary) type

Properties
Name Type Description
name

Buffer (binary) type

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

Arguments
Name Type Description
value any

Buffer (binary) type

options Options

Buffer (binary) type

defaultValue() : Buffer

isCoercible(value: any) : boolean

Arguments
Name Type Description
value any

Buffer (binary) type

isInstance(value: any) : boolean

Arguments
Name Type Description
value any

Buffer (binary) type

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

Arguments
Name Type Description
value

Buffer (binary) type

options Options

Buffer (binary) type

Class: datetype = new DateType()

Date type

Properties
Name Type Description
name

Date type

coerce(value: any) : any

Arguments
Name Type Description
value any

Date type

defaultValue() : Date

isCoercible(value: any) : boolean

Arguments
Name Type Description
value any

Date type

isInstance(value: any) : boolean

Arguments
Name Type Description
value any

Date type

serialize(value: undefined) : string | Date

Arguments
Name Type Description
value

Date type

Class: modeltype = new ModelType()

Model type

Properties
Name Type Description
modelClass Class

Model type

name string

Model type

constructor(modelClass: Class) : ModelType

Model type

Arguments
Name Type Description
modelClass Class

Model type

serialize(value: undefined) : Object

Arguments
Name Type Description
value

Model type

Class: numbertype = new NumberType()

Number type

Properties
Name Type Description
name

Number type

coerce(value: any) : any

Arguments
Name Type Description
value any

Number type

defaultValue() : number

isCoercible(value: any) : boolean

Arguments
Name Type Description
value any

Number type

isInstance(value: any) : boolean

Arguments
Name Type Description
value any

Number type

serialize(value: undefined) : number

Arguments
Name Type Description
value

Number type

Class: stringtype = new StringType()

String type

Properties
Name Type Description
name

String type

coerce(value: any) : string

Arguments
Name Type Description
value any

String type

defaultValue() : string

isCoercible(value: any) : boolean

Arguments
Name Type Description
value any

String type

isInstance(value: any) : boolean

Arguments
Name Type Description
value any

String type

serialize(value: undefined) : string

Arguments
Name Type Description
value

String type

Interface: Type

Properties
Name Type Description
name string

Name of the type

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

Coerce the value into this type

Returns:

Coerced value of this type

Arguments
Name Type Description
value any

The value to be coerced

options Options

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

Arguments
Name Type Description
value any

The value to to be coerced

options Options

isInstance(value: any) : boolean

Test if the given value is an instance of this type

Arguments
Name Type Description
value any

The value

serialize(value: undefined, options: Options) : any

Serialize a value into json

Arguments
Name Type Description
value

The value of this type

options Options

Options for serialization

Class: uniontype = new UnionType()

Union type, such as string | number

Properties
Name Type Description
itemTypes

Union type, such as string | number

name

Union type, such as string | number

constructor(itemTypes: undefined) : UnionType

Union type, such as string | number

Arguments
Name Type Description
itemTypes

Union type, such as string | number

coerce(value: any) : any

Arguments
Name Type Description
value any

Union type, such as string | number

defaultValue() : any

isCoercible(value: any) : boolean

Arguments
Name Type Description
value any

Union type, such as string | number

isInstance(value: any) : boolean

Arguments
Name Type Description
value any

Union type, such as string | number

serialize(value: any) : any

Arguments
Name Type Description
value any

Union type, such as string | number