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

AbstractStorage

Abstract storage for Vo. Any method here must be implemented. If not, will throw a StorageError

Constructor Summary

Public Constructor
public

constructor(collection: Object | Array | String)

Member Summary

Public Members
public get

Method Summary

Public Methods
public abstract

delete(criteria: Object): Promise<integer, Error>

Delete collection Object from criteria

public abstract

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

Get a list of data Object from criteria and options

public abstract

insert(Object[]: *): Promise<Object[], Error>

Insert many data Object in storage

public abstract

update(criteria: Object, newValues: Object, options: Object): Promise<integer, Error>

Update collection from criteria

Public Constructors

public constructor(collection: Object | Array | String) source

Params:

NameTypeAttributeDescription
collection Object | Array | String
  • nullable: true

the sotorage collection

Public Members

public get collection: Object | Array | String source

Public Methods

public abstract delete(criteria: Object): Promise<integer, Error> source

Delete collection Object from criteria

Params:

NameTypeAttributeDescription
criteria Object

MongoDb criteria Object

Return:

Promise<integer, Error>

number of deleted items

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

Get a list of data Object from criteria and options

Params:

NameTypeAttributeDescription
criteria Object

mongodb criteria style

options Object

mongodb options style

Return:

Promise<Object[], Error>

public abstract insert(Object[]: *): Promise<Object[], Error> source

Insert many data Object in storage

Params:

NameTypeAttributeDescription
Object[] *
  • optional

dataArray - a list of data Object

Return:

Promise<Object[], Error>

inserted data Object list

public abstract update(criteria: Object, newValues: Object, options: Object): Promise<integer, Error> source

Update collection from criteria

Params:

NameTypeAttributeDescription
criteria Object

MongoDb criteria Object

newValues Object

key-value Object with new data

options Object

Storage option

Return:

Promise<integer, Error>

number of updated items