Interface: AnyObject

Objects with open properties

Interface: Class

Interface for classes with new operator and static properties/methods

constructor(args: undefined) : T

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

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

Type alias for Node.js callback functions

Arguments
Name Type Description
err
result T

Type alias: NamedParameters = AnyObject

Type alias: PositionalParameters = any[]

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

execute(command: Command, parameters: undefined, options: Options) : Promise

Arguments
Name Type Description
command Command

Common properties/operations for connectors

parameters

Common properties/operations for connectors

options Options

Common properties/operations for connectors

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

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.

Arguments
Name Type Description
target Function

The class from which to retrieve metadata.

options InspectionOptions

An options object for the MetadataInspector to customize the output of the metadata retrieval functions.

Function: property.array

property.array(itemType: Function, definition: Partial) : (Anonymous function)

Arguments
Name Type Description
itemType Function

The class of the array to decorate

definition Partial

Optional PropertyDefinition object for additional metadata

Type alias: PropertyMap = MetadataMap

Function: model

model(definition: Partial) : (Anonymous function)

Decorator for model definitions

Arguments
Name Type Description
definition Partial

Class: relationmetadata = new RelationMetadata()

Properties
Name Type Description
as string
target
type RelationType

Function: belongsTo

belongsTo(definition: Object) :

Decorator for belongsTo

Arguments
Name Type Description
definition Object

Function: embedsMany

embedsMany(definition: Object) :

Decorator for embedsMany

Arguments
Name Type Description
definition Object

Function: embedsOne

embedsOne(definition: Object) :

Decorator for embedsOne

Arguments
Name Type Description
definition Object

Function: hasMany

hasMany(definition: Object) :

Decorator for hasMany

Arguments
Name Type Description
definition Object

Function: hasOne

hasOne(definition: Object) :

Decorator for hasOne

Arguments
Name Type Description
definition Object

Function: referencesMany

referencesMany(definition: Object) :

Decorator for referencesMany

Arguments
Name Type Description
definition Object

Function: referencesOne

referencesOne(definition: Object) :

Decorator for referencesOne

Arguments
Name Type Description
definition Object

Function: relation

relation(definition: Object) :

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

Name of the data source

modelClass

Class of the model

modelName

Name of the model

name

Name of the predefined repository

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

Constructor for RepositoryMetadata

Arguments
Name Type Description
modelOrRepo

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

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, descriptorOrIndex: undefined): void

Type definition for decorators returned by @repository decorator factory

Arguments
Name Type Description
target Object
key
descriptorOrIndex

Function: repository

repository(repositoryName: undefined) : RepositoryDecorator

Decorator for repository injections on properties or method arguments

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

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

Arguments
Name Type Description
repositoryName

Name of the repo

repository(model: undefined, dataSource: undefined) : 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
    >,
  ) {}
  // ...
}

Arguments
Name Type Description
model

Name/class of the model

dataSource

Name/instance of the dataSource

Class: juggler.datasource = new juggler.DataSource()

DataSource instance properties/operations

Properties
Name Type Description
connected

DataSource instance properties/operations

connecting

DataSource instance properties/operations

name string

DataSource instance properties/operations

settings AnyObject

DataSource instance properties/operations

constructor(name: undefined, settings: AnyObject, modelBuilder: ModelBuilder) : DataSource

Arguments
Name Type Description
name

DataSource instance properties/operations

settings AnyObject

DataSource instance properties/operations

modelBuilder ModelBuilder

DataSource instance properties/operations

constructor(settings: AnyObject, modelBuilder: ModelBuilder) : DataSource

Arguments
Name Type Description
settings AnyObject

DataSource instance properties/operations

modelBuilder ModelBuilder

DataSource instance properties/operations

createModel(name: string, properties: AnyObject, options: Options) : T

Create a model class

Arguments
Name Type Description
name string

Name of the model

properties AnyObject

An object of property definitions

options Options

Options for model settings

Class: juggler.keyvaluemodel = new juggler.KeyValueModel()

expire(key: string, ttl: number, options: Options, callback: Callback) : PromiseOrVoid

Set the TTL (time to live) in ms (milliseconds) for a given key. TTL is the remaining time before a key-value pair is discarded from the database.

Arguments
Name Type Description
key string

Key to use when searching the database.

ttl number

TTL in ms to set for the key.

options Options
callback Callback

get(key: string, options: Options, callback: Callback) : PromiseOrVoid

Return the value associated with a given key.

Arguments
Name Type Description
key string

Key to use when searching the database.

options Options
callback Callback

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

Asynchronously iterate all keys in the database. Similar to .keys() but instead allows for iteration over large data sets without having to load everything into memory at once.

Callback example:

// Given a model named `Color` with two keys `red` and `blue`
var iterator = Color.iterateKeys();
it.next(function(err, key) {
  // key contains `red`
  it.next(function(err, key) {
    // key contains `blue`
  });
});

Promise example:

// Given a model named `Color` with two keys `red` and `blue`
var iterator = Color.iterateKeys();
Promise.resolve().then(function() {
  return it.next();
})
.then(function(key) {
  // key contains `red`
  return it.next();
});
.then(function(key) {
  // key contains `blue`
});

Returns:

An Object implementing next(cb) -> Promise function that can be used to iterate all keys.

Arguments
Name Type Description
filter Filter

An optional filter object with the following

options Options

keys(filter: Filter, options: Options, callback: Callback) : PromiseOrVoid

Return all keys in the database.

WARNING: This method is not suitable for large data sets as all key-values pairs are loaded into memory at once. For large data sets, use iterateKeys() instead.

Arguments
Name Type Description
filter Filter

An optional filter object with the following

options Options

callback Callback

set(key: string, value: KVData, options: Options, callback: Callback) : PromiseOrVoid

Persist a value and associate it with the given key.

Arguments
Name Type Description
key string

Key to associate with the given value.

value KVData

Value to persist.

options Options
callback Callback

ttl(key: string, options: Options, callback: Callback) : PromiseOrVoid

Return the TTL (time to live) for a given key. TTL is the remaining time before a key-value pair is discarded from the database.

Arguments
Name Type Description
key string

Key to use when searching the database.

options Options
callback Callback

Class: juggler.modelbase = new juggler.ModelBase()

Base model class

Properties
Name Type Description
dataSource DataSource

Base model class

definition ModelDefinition

Base model class

modelName string

Base model class

constructor(args: undefined) : ModelBase

Arguments
Name Type Description
args

Base model class

toJSON() : Object

toObject(options: Options) : Object

Arguments
Name Type Description
options Options

Base model class

attachTo(ds: DataSource) : void

Arguments
Name Type Description
ds DataSource

Base model class

Class: juggler.modelbuilder = new juggler.ModelBuilder()

Properties
Name Type Description
definitions Function
models Function
settings AnyObject
defaultInstance ModelBuilder

buildModelFromInstance(name: string, json: AnyObject, options: Options) : ModelBase

Arguments
Name Type Description
name string
json AnyObject
options Options

buildModels(schemas: AnyObject, createModel: Function) :

Arguments
Name Type Description
schemas AnyObject
createModel Function

define(className: string, properties: AnyObject, settings: AnyObject, parent: undefined) : ModelBase

Arguments
Name Type Description
className string
properties AnyObject
settings AnyObject
parent

defineProperty(modelName: string, propertyName: string, propertyDefinition: AnyObject) : void

Arguments
Name Type Description
modelName string
propertyName string
propertyDefinition AnyObject

defineValueType(type: string, aliases: undefined) : void

Arguments
Name Type Description
type string
aliases

extendModel(modelName: string, properties: AnyObject) : void

Arguments
Name Type Description
modelName string
properties AnyObject

getModel(name: string, forceCreate: undefined) : ModelBase

Arguments
Name Type Description
name string
forceCreate

getModelDefinition(name: string) : ModelDefinition | undefined

Arguments
Name Type Description
name string

getSchemaName(name: undefined) : string

Arguments
Name Type Description
name

resolveType(type: any) : any

Arguments
Name Type Description
type any

Class: juggler.modeldefinition = new juggler.ModelDefinition()

Model definition

Properties
Name Type Description
name string

Model definition

properties AnyObject

Model definition

rawProperties AnyObject

Model definition

relations

Model definition

settings AnyObject

Model definition

constructor(modelBuilder: undefined, name: string, properties: undefined, settings: AnyObject) : ModelDefinition

Arguments
Name Type Description
modelBuilder

Model definition

name string

Model definition

properties

Model definition

settings AnyObject

Model definition

constructor(modelBuilder: undefined, schema: Schema) : ModelDefinition

Arguments
Name Type Description
modelBuilder

Model definition

schema Schema

Model definition

build(forceRebuild: undefined) : AnyObject

Arguments
Name Type Description
forceRebuild

Model definition

columnMetadata(connectorType: string, propertyName: string) : ColumnMetadata

Arguments
Name Type Description
connectorType string

Model definition

propertyName string

Model definition

columnName(connectorType: string, propertyName: string) : string

Arguments
Name Type Description
connectorType string

Model definition

propertyName string

Model definition

columnNames(connectorType: string) :

Arguments
Name Type Description
connectorType string

Model definition

defineProperty(propertyName: string, propertyDefinition: PropertyDefinition) : void

Arguments
Name Type Description
propertyName string

Model definition

propertyDefinition PropertyDefinition

Model definition

idName() : string

idNames() :

ids() :

indexes() :

tableName(connectorType: string) : string

Arguments
Name Type Description
connectorType string

Model definition

toJSON(forceRebuild: undefined) : AnyObject

Arguments
Name Type Description
forceRebuild

Model definition

Class: juggler.persistedmodel = new juggler.PersistedModel()

delete(options: Options, callback: Callback) : PromiseOrVoid

Arguments
Name Type Description
options Options
callback Callback

destroy(options: Options, callback: Callback) : PromiseOrVoid

Deletes the model from persistence. Triggers destroy hook (async) before and after destroying object.

Arguments
Name Type Description
options Options
callback Callback

Callback function.

getId() : any

Get the id value for the PersistedModel.

Returns:

The id value

getIdName() : string

Get the id property name of the constructor.

Returns:

The id property name

isNewRecord() : boolean

Determine if the data model is new.

Returns:

Returns true if the data model is new; false otherwise.

reload(options: Options, callback: Callback) : PromiseOrVoid

Reload object from persistence. Requires id member of object to be able to call find.

Arguments
Name Type Description
options Options
callback Callback

remove(options: Options, callback: Callback) : PromiseOrVoid

Arguments
Name Type Description
options Options
callback Callback

replaceAttributes(data: PersistedData, options: Options, callback: Callback) : PromiseOrVoid

Replace attributes for a model instance and persist it into the datasource. Performs validation before replacing.

Arguments
Name Type Description
data PersistedData

Data to replace.

options Options
callback Callback

save(options: Options, callback: Callback) : PromiseOrVoid

Save model instance. If the instance doesn't have an ID, then calls create instead. Triggers: validate, save, update, or create.

Arguments
Name Type Description
options Options
callback Callback

setId(val: any) : void

Set the correct id property for the PersistedModel. Uses the setId method if the model is attached to connector that defines it. Otherwise, uses the default lookup. Override this method to handle complex IDs.

Arguments
Name Type Description
val any

The id value. Will be converted to the type that the id property specifies.

updateAttribute(name: string, value: any, options: Options, callback: Callback) : PromiseOrVoid

Update a single attribute. Equivalent to updateAttributes({name: 'value'}, cb)

Arguments
Name Type Description
name string

Name of property.

value any

Value of property.

options Options
callback Callback

updateAttributes(data: PersistedData, options: Options, callback: Callback) : PromiseOrVoid

Update set of attributes. Performs validation before updating.

Triggers: validation, save and update hooks

Arguments
Name Type Description
data PersistedData

Data to update.

options Options
callback Callback

count(where: Where, options: Options, callback: Callback) : PromiseOrVoid

Return the number of records that match the optional "where" filter.

Arguments
Name Type Description
where Where
options Options
callback Callback

create(data: PersistedData, options: Options, callback: Callback) : PromiseOrVoid

Create new instance of Model, and save to database.

Arguments
Name Type Description
data PersistedData
options Options
callback Callback

deleteAll(where: Where, options: Options, callback: Callback) : PromiseOrVoid

Arguments
Name Type Description
where Where
options Options
callback Callback

deleteById(id: any, options: Options, callback: Callback) : PromiseOrVoid

Arguments
Name Type Description
id any
options Options
callback Callback

destroyAll(where: Where, options: Options, callback: Callback) : PromiseOrVoid

Destroy all model instances that match the optional where specification.

Arguments
Name Type Description
where Where
options Options
callback Callback

destroyById(id: any, options: Options, callback: Callback) : PromiseOrVoid

Destroy model instance with the specified ID.

Arguments
Name Type Description
id any

The ID value of model instance to delete.

options Options
callback Callback

exists(id: any, options: Options, callback: Callback) : PromiseOrVoid

Check whether a model instance exists in database.

Arguments
Name Type Description
id any

Identifier of object (primary key value).

options Options
callback Callback

find(filter: Filter, options: Options, callback: Callback) : PromiseOrVoid

Find all model instances that match filter specification. See Querying models.

Arguments
Name Type Description
filter Filter
options Options
callback Callback

findById(id: any, filter: Filter, options: Options, callback: Callback) : PromiseOrVoid

Find object by ID with an optional filter for include/fields.

Arguments
Name Type Description
id any

Primary key value

filter Filter
options Options
callback Callback

findOne(filter: Filter, options: Options, callback: Callback) : PromiseOrVoid

Find one model instance that matches filter specification. Same as find, but limited to one result; Returns object, not collection.

Arguments
Name Type Description
filter Filter
options Options
callback Callback

findOrCreate(filter: Filter, data: PersistedData, options: Options, callback: Callback) : PromiseOrVoid

Finds one record matching the optional filter object. If not found, creates the object using the data provided as second argument. In this sense it is the same as find, but limited to one object. Returns an object, not collection. If you don't provide the filter object argument, it tries to locate an existing object that matches the data argument.

Arguments
Name Type Description
filter Filter
data PersistedData

Data to insert if object matching the where filter is not found.

options Options
callback Callback

getIdName() : string

Get the id property name of the constructor.

Returns:

The id property name

patchOrCreate(data: PersistedData, options: Options, callback: Callback) : PromiseOrVoid

Arguments
Name Type Description
data PersistedData
options Options
callback Callback

patchOrCreateWithWhere(where: Where, data: PersistedData, options: Options, callback: Callback) : PromiseOrVoid

Arguments
Name Type Description
where Where
data PersistedData
options Options
callback Callback

remove(where: Where, options: Options, callback: Callback) : PromiseOrVoid

Arguments
Name Type Description
where Where
options Options
callback Callback

removeById(id: any, options: Options, callback: Callback) : PromiseOrVoid

Arguments
Name Type Description
id any
options Options
callback Callback

replaceById(id: any, data: PersistedData, options: Options, callback: Callback) : PromiseOrVoid

Replace attributes for a model instance whose id is the first input argument and persist it into the datasource. Performs validation before replacing.

Arguments
Name Type Description
id any

The ID value of model instance to replace.

data PersistedData

Data to replace.

options Options
callback Callback

replaceOrCreate(data: PersistedData, options: Options, callback: Callback) : PromiseOrVoid

Replace or insert a model instance; replace existing record if one is found, such that parameter data.id matches id of model instance; otherwise, insert a new record.

Arguments
Name Type Description
data PersistedData

The model instance data.

options Options
callback Callback

update(where: Where, data: PersistedData, options: Options, callback: Callback) : PromiseOrVoid

Arguments
Name Type Description
where Where
data PersistedData
options Options
callback Callback

updateAll(where: Where, data: PersistedData, options: Options, callback: Callback) : PromiseOrVoid

Update multiple instances that match the where clause.

Example:

Employee.updateAll({managerId: 'x001'}, {managerId: 'x002'}, function(err, info) {
    ...
});

Arguments
Name Type Description
where Where
data PersistedData

Object containing data to replace matching instances, if AnyType.

options Options
callback Callback

updateOrCreate(data: PersistedData, options: Options, callback: Callback) : PromiseOrVoid

Arguments
Name Type Description
data PersistedData
options Options
callback Callback

upsert(data: PersistedData, options: Options, callback: Callback) : PromiseOrVoid

Update or insert a model instance

Arguments
Name Type Description
data PersistedData

The model instance data to insert.

options Options
callback Callback

upsertWithWhere(where: Where, data: PersistedData, options: Options, callback: Callback) : PromiseOrVoid

Update or insert a model instance based on the search criteria. If there is a single instance retrieved, update the retrieved model. Creates a new model if no model instances were found. Returns an error if multiple instances are found.

Arguments
Name Type Description
where Where
data PersistedData

The model instance data to insert.

options Options
callback Callback

Interface: juggler.ColumnMetadata

Column metadata

Properties
Name Type Description
name string

Column metadata

Interface: juggler.Condition

Properties
Name Type Description
and
between
eq any
exists
gt any
gte any
inq
lt any
lte any
neq any
or

Interface: juggler.Count

Properties
Name Type Description
count number

Interface: juggler.Fields

Selection of fields

Interface: juggler.Filter

Query filter object

Properties
Name Type Description
fields Fields

Query filter object

include

Query filter object

limit

Query filter object

offset

Query filter object

order

Query filter object

skip

Query filter object

where Where

Query filter object

Interface: juggler.IdDefinition

ID definition

Properties
Name Type Description
id number

ID definition

name string

ID definition

property AnyObject

ID definition

Interface: juggler.Inclusion

Inclusion of related items

Properties
Name Type Description
relation string

Inclusion of related items

scope Filter

Inclusion of related items

Interface: juggler.IndexDefinition

Index definition

Interface: juggler.PropertyDefinition

Property definition

Properties
Name Type Description
name string

Property definition

type any

Property definition

Interface: juggler.RelationDefinition

Relation definition

Properties
Name Type Description
name string

Relation definition

type string

Relation definition

Interface: juggler.Schema

Schema definition

Properties
Name Type Description
name string

Schema definition

properties AnyObject

Schema definition

settings AnyObject

Schema definition

Interface: juggler.Where

Where object

Properties
Name Type Description
and

Where object

or

Where object

Type alias: juggler.KVData = ModelData

Type alias: juggler.PersistedData = ModelData

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

Interface: AppWithRepository

Interface for an Application mixed in with RepositoryMixin

Properties
Name Type Description
options ApplicationConfig

Interface for an Application mixed in with RepositoryMixin

component(component: Class) : void

Arguments
Name Type Description
component Class

Interface for an Application mixed in with RepositoryMixin

dataSource(dataSource: DataSource, name: undefined) : void

Arguments
Name Type Description
dataSource DataSource

Interface for an Application mixed in with RepositoryMixin

name

Interface for an Application mixed in with RepositoryMixin

getRepository(repo: Class) : Promise

Arguments
Name Type Description
repo Class

Interface for an Application mixed in with RepositoryMixin

mountComponentRepository(component: Class) : void

Arguments
Name Type Description
component Class

Interface for an Application mixed in with RepositoryMixin

repository(repo: Class) : void

Arguments
Name Type Description
repo Class

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) {}

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

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

constructor(data: Partial) : Model

Arguments
Name Type Description
data Partial

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(nameOrDef: undefined) : ModelDefinition

Arguments
Name Type Description
nameOrDef

Definition for a model

addProperty(name: string, definitionOrType: undefined) : this

Add a property

Arguments
Name Type Description
name string

Definition for a model

definitionOrType

Definition for a model

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 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 Description
name string

DSL for building a model definition.

properties

DSL for building a model definition.

settings

DSL for building a model definition.

Interface: Persistable

Interface: PropertyDefinition

Property definition for a model

Properties
Name Type Description
id

Property definition for a model

json PropertyForm

Property definition for a model

store PropertyForm

Property definition for a model

type PropertyType

Property definition for a model

Interface: PropertyDefinitionMap

Interface: PropertyForm

Properties
Name Type Description
in
name
out

Type alias: EntityData = DataObject

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 Description
filter Filter

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

constructor(f: Filter) : FilterBuilder

Arguments
Name Type Description
f Filter

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: undefined) : this

Describe what fields to be included/excluded

Arguments
Name Type Description
f

A field name to be included, an array of field names to be included, or an Fields object for the inclusion/exclusion

include(i: undefined) : this

Declare include

Arguments
Name Type Description
i

A relation name, an array of relation names, or an Inclusion object for the relation/scope definitions

limit(limit: number) : this

Set limit

Arguments
Name Type Description
limit number

Maximum number of records to be returned

offset(offset: number) : this

Set offset

Arguments
Name Type Description
offset number

Offset of the number of records to be returned

order(o: undefined) : this

Describe the sorting order

Arguments
Name Type Description
o

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

Arguments
Name Type Description
skip number

where(w: Where) : this

Declare a where clause

Arguments
Name Type 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 Description
where Where

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

constructor(w: Where) : WhereBuilder

Arguments
Name Type Description
w Where

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

and(w: undefined) : this

Add an and clause.

Arguments
Name Type Description
w

One or more where objects

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

Add a between condition

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

Arguments
Name Type Description
key string

Property name

val any

Property value

exists(key: string, val: undefined) : this

Add a exists condition

Arguments
Name Type Description
key string

Property name

val

Exists or not

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

Add a > condition

Arguments
Name Type Description
key string

Property name

val any

Property value

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

Add a >= condition

Arguments
Name Type Description
key string

Property name

val any

Property value

inq(key: string, val: undefined) : this

Add a inq condition

Arguments
Name Type Description
key string

Property name

val

An array of property values

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

Add a < condition

Arguments
Name Type Description
key string

Property name

val any

Property value

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

Add a <= condition

Arguments
Name Type Description
key string

Property name

val any

Property value

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

Add a != condition

Arguments
Name Type Description
key string

Property name

val any

Property value

or(w: undefined) : this

Add an or clause.

Arguments
Name Type Description
w

One or more where objects

Interface: Condition

Matching condition

Properties
Name Type Description
and

Matching condition

between

Matching condition

eq any

Matching condition

exists

Matching condition

gt any

Matching condition

gte 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

Maximum number of entities

offset

Offset N number of entities. An alias for skip

order

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

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'}]}

Function: filterTemplate

filterTemplate(strings: TemplateStringsArray, keys: undefined) : filter

Arguments
Name Type Description
strings TemplateStringsArray
keys

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

Legacy data source

entityClass

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

modelClass PersistedModel

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

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

Constructor of DefaultCrudRepository

Arguments
Name Type Description
entityClass

Constructor of DefaultCrudRepository

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

Arguments
Name Type Description
entity Partial

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

Arguments
Name Type Description
entity T

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

execute(command: Command, parameters: undefined, options: Options) : Promise

Arguments
Name Type Description
command Command

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

parameters

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

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

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

Arguments
Name Type Description
id ID

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

data Partial

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

Arguments
Name Type Description
entity T

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

Arguments
Name Type Description
entity T

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

Arguments
Name Type Description
data Partial

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

Arguments
Name Type Description
id ID

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

data Partial

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

Type alias: DataSourceType = DataSource

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

Arguments
Name Type Description
modelClass T

Model class

ds DataSource

Data source

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

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

execute(command: Command, parameters: undefined, options: Options) : Promise

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

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

execute(command: Command, parameters: undefined, options: Options) : Promise

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

Arguments
Name Type Description
command Command

The query string or command object

parameters

The object with name/value pairs or an array of parameter values

options Options

Options

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

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

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) : undefined | null | string

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) : undefined | null | string

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

Arguments
Name Type Description
modelClass Class

Model type

serialize(value: undefined) : undefined | null | 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) : undefined | null | number

Arguments
Name Type Description
value

Number type

Class: objecttype = new ObjectType()

Object type

Properties
Name Type Description
name string

Object type

type Class

Object type

constructor(type: Class) : ObjectType

Arguments
Name Type Description
type Class

Object type

coerce(value: any) : any

Arguments
Name Type Description
value any

Object type

defaultValue() : T

isCoercible(value: any) : boolean

Arguments
Name Type Description
value any

Object type

isInstance(value: any) : boolean

Arguments
Name Type Description
value any

Object type

serialize(value: undefined) : any

Arguments
Name Type Description
value

Object 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) : undefined | null | 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

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