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

Service

Execute any business request from business data. Mostly output Vo

Constructor Summary

Public Constructor
public

constructor(manager: Manager)

Member Summary

Public Members
public get

Get the list of Class available methods

Method Summary

Public Methods
public

Create a Vo from a data object

public

Delete a Vo from its id

public

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

Get a list of Vo

public

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

Get a paginated list of Vo

public

Get a Vo from its Id

public

setContext(key: string, value: number | string | Array | object): self

Store a context

public

setFullContext(context: object): self

Store and override all context

public

Update a Vo properties from a dataset

Public Constructors

public constructor(manager: Manager) source

Params:

NameTypeAttributeDescription
manager Manager

manager a manager instance

Public Members

public get availableMethods: String[]: * source

Get the list of Class available methods

Return:

String[]

the list of the callable methods

Public Methods

public createOneFromData(data: object): Promise<Vo, Error> source

Create a Vo from a data object

Params:

NameTypeAttributeDescription
data object

Return:

Promise<Vo, Error>

new Vo

public deleteOneById(id: string): Promise<boolean, Error> source

Delete a Vo from its id

Params:

NameTypeAttributeDescription
id string

the id of the Vo

Return:

Promise<boolean, Error>

true if success, false if error, null if nothing to delete

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 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 getOneById(id: string): Promise<Vo, Error> source

Get a Vo from its Id

Params:

NameTypeAttributeDescription
id string

the id of the Vo

Return:

Promise<Vo, Error>

public setContext(key: string, value: number | string | Array | object): self source

Store a context

Params:

NameTypeAttributeDescription
key string

the context key

value number | string | Array | object
  • nullable: true

the context value

Return:

self

public setFullContext(context: object): self source

Store and override all context

Params:

NameTypeAttributeDescription
context object

the context key

Return:

self

public updateOneFromData(data: Object): Promise<Vo, Error> source

Update a Vo properties from a dataset

Params:

NameTypeAttributeDescription
data Object

a data object

Return:

Promise<Vo, Error>

the updated Vo