Home Identifier Source Repository
import Manager from 'piggy-module/src/Manager.js'
public class | source

Manager

Manage Vo items, sending and getting them to the Storage

Constructor Summary

Public Constructor
public

constructor(storage: *)

Member Summary

Public Members
public get

Get the list of Class available methods

public

storage: Storage

Method Summary

Public Methods
public

Make sure an object has the current Manager Vo class

public

Delete a list of Vo in storage

public

Delete a vo in storage

public

get(criteria: Object, options: Object): Promise<Vo[], Error>

Get a list of Vo

public

getAllVoErrors(vo: Vo, skipProperties: string[]): Promise<object, Error>

Get a list of all error of a Vo

public

getByPage(criteria: Object, page: integer, limit: integer, orderby: string, order: string): Promise<Vo[], Error>

Get a paginated list of Vo

public

getByUniqueProperty(property: string, value: any): Promise<Vo, Error>

Get a Vo from a unique property value

public

getByUniquePropertyM(property: string, values: any[]): Promise<Vo[], Error>

Get a list of Vo from a unique property and many values

public

getNewVo(data: object): Vo

Get a new Vo, and fill it with data if any

public

Get a list of the properties business errors of a Vo.

public

Get a list of the properties format error of a Vo

public

Get a list of the unique properties error of a Vo

public

Insert a vo in storage

public

saveOne(vo: Vo): Promise<Vo[], Error>

Save a vo in storage, update if exists, or insert

public

Update a vo in storage

Public Constructors

public constructor(storage: *) source

Params:

NameTypeAttributeDescription
storage *

Public Members

public get availableMethods: String[]: * source

Get the list of Class available methods

Return:

String[]

the list of the callable methods

public storage: Storage source

Public Methods

public assumeIsOwnVoClass(vo: Vo) source

Make sure an object has the current Manager Vo class

Params:

NameTypeAttributeDescription
vo Vo

public delete(Vo: Vo[]): Promise<boolean, Error> source

Delete a list of Vo in storage

Params:

NameTypeAttributeDescription
Vo Vo[]

to delete

Return:

Promise<boolean, Error>

number of deleted item

public deleteOne(vo: Vo): Promise<boolean, Error> source

Delete a vo in storage

Params:

NameTypeAttributeDescription
vo Vo

Return:

Promise<boolean, Error>

number of deleted item

public get(criteria: Object, options: Object): Promise<Vo[], Error> source

Get a list of Vo

Params:

NameTypeAttributeDescription
criteria Object

mongodb-like criteria style

options Object

mongodb-like options style

Return:

Promise<Vo[], Error>

public getAllVoErrors(vo: Vo, skipProperties: string[]): Promise<object, Error> source

Get a list of all error of a Vo

Params:

NameTypeAttributeDescription
vo Vo

the Vo to check

skipProperties string[]

a list of properties not to check

Return:

Promise<object, Error>

list of message errors (key: property, value: message)

public getByPage(criteria: Object, page: integer, limit: integer, orderby: string, order: string): Promise<Vo[], Error> source

Get a paginated list of Vo

Params:

NameTypeAttributeDescription
criteria Object

mongodb-like criteria style

page integer

the page to retrieve

limit integer

number of item per page

orderby string

a Vo property to order by

order string

'asc' or 'desc'

Return:

Promise<Vo[], Error>

public getByUniqueProperty(property: string, value: any): Promise<Vo, Error> source

Get a Vo from a unique property value

Params:

NameTypeAttributeDescription
property string
value any

the unique property value to look for

Return:

Promise<Vo, Error>

public getByUniquePropertyM(property: string, values: any[]): Promise<Vo[], Error> source

Get a list of Vo from a unique property and many values

Params:

NameTypeAttributeDescription
property string
values any[]

the unique property value to look for

Return:

Promise<Vo[], Error>

public getNewVo(data: object): Vo source

Get a new Vo, and fill it with data if any

Params:

NameTypeAttributeDescription
data object
  • nullable: true

Return:

Vo

public getVoBusinessErrors(vo: Vo): Promise<object, Error> source

Get a list of the properties business errors of a Vo. To be override by business specific needs

Params:

NameTypeAttributeDescription
vo Vo

the Vo to check

Return:

Promise<object, Error>

list of message errors (key: property, value: message)

public getVoFormatErrors(vo: Vo): Promise<object, Error> source

Get a list of the properties format error of a Vo

Params:

NameTypeAttributeDescription
vo Vo

the Vo to check

Return:

Promise<object, Error>

list of message errors (key: property, value: message)

public getVoUniqueErrors(vo: Vo): Promise<object, Error> source

Get a list of the unique properties error of a Vo

Params:

NameTypeAttributeDescription
vo Vo

the Vo to check

Return:

Promise<object, Error>

list of message errors (key: property, value: message)

public insertOne(vo: Vo): Promise<Vo[], Error> source

Insert a vo in storage

Params:

NameTypeAttributeDescription
vo Vo

Return:

Promise<Vo[], Error>

public saveOne(vo: Vo): Promise<Vo[], Error> source

Save a vo in storage, update if exists, or insert

Params:

NameTypeAttributeDescription
vo Vo

Return:

Promise<Vo[], Error>

public updateOne(vo: Vo): Promise<Vo[], Error> source

Update a vo in storage

Params:

NameTypeAttributeDescription
vo Vo

Return:

Promise<Vo[], Error>