Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Store<T, K>

This class handle NoSQL storage and mapping (duplication) between NoSQL object TODO Create the mapping documentation

It use basic CRUD, and can expose those 4 to through HTTP

It emits events : Store.Save: Before saving the object Store.Saved: After saving the object Store.Update: Before updating the object Store.Updated: After updating the object Store.Delete: Before deleting the object Store.Deleted: After deleting the object Store.Get: When getting the object Store.Action: When an action will be done on an object Store.Actioned: When an action has been done on an object

Mapping:

Parameters

map: { ... } expose: { // Enable the HTTP exposure url: '', // The url to expose to by default it is service name in lowercase ( users for example ) restrict: { create: true, // Don't expose the POST /users update: true, // Don't expose the PUT /users/{uuid} delete: true, // Don't expose the DELETE /users/{uuid} get: true // Don't expose the GET /users/{uuid} } }

Type parameters

Hierarchy

Implements

Constructors

  • new Store(webda: Core, name: string, params?: any): Store

Properties

_cascade: any[] = []
_createException: string
_creationDateField: string
_exposeUrl: string
_initException: any = undefined
_initTime: number
_lastUpdateField: string
_name: string

Service name

_reverseMap: any[] = []
_uuidField: string = "uuid"
_webda: Core

Webda Core object

logger: Logger

Logger with class context

parameters: K

Hold the parameters for your service

It will be bring from the webda.config.json

defaultMaxListeners: number

Methods

  • __clean(): Promise<any>
  • _delete(uid: string, writeCondition?: any, itemWriteConditionField?: string): Promise<void>
  • _deleteItemFromCollection(uid: any, prop: any, index: any, itemWriteCondition: any, itemWriteConditionField: any, updateDate: Date): Promise<any>
  • _find(request: any, offset: any, limit: any): Promise<void>
  • _get(uid: string): Promise<any>
  • _handleCreatedMap(object: any, map: any, mapped: any, store: any): any
  • _handleDeletedMap(object: any, map: any, mapped: any, store: any): any
  • _handleMapFromPartial(uid: string, updateDate: Date, prop?: string): Promise<void>
  • _handleMapProperty(store: any, object: any, property: any, updates: any): Promise<any>
  • _handleUpdatedMap(object: any, map: any, mapped: any, store: any, updates: any): Promise<any>
  • _handleUpdatedMapMapper(object: any, map: any, mapped: any, store: any, updates: any): any
  • _handleUpdatedMapTransferIn(object: any, map: any, store: any, updates: any): any
  • _handleUpdatedMapTransferOut(object: any, map: any, mapped: any, store: any, updates: any): any
  • _incrementAttribute(uid: any, prop: any, value: any, updateDate: Date): Promise<any>
  • _patch(object: any, uid: string, itemWriteCondition?: any, itemWriteConditionField?: string): Promise<any>
  • Parameters

    • object: any
    • uid: string
    • Default value itemWriteCondition: any = undefined
    • Default value itemWriteConditionField: string = undefined

    Returns Promise<any>

  • _removeAttribute(uuid: string, attribute: string): Promise<void>
  • _update(object: any, uid: any, itemWriteCondition?: any, itemWriteConditionField?: string): Promise<any>
  • Parameters

    • object: any
    • uid: any
    • Default value itemWriteCondition: any = undefined
    • Default value itemWriteConditionField: string = undefined

    Returns Promise<any>

  • _upsertItemToCollection(uid: any, prop: any, item: any, index: any, itemWriteCondition: any, itemWriteConditionField: any, updateDate: Date): Promise<any>
  • addListener(event: string | symbol, listener: function): this
  • addReverseMap(prop: any, cascade: any, store: any): void
  • addRoute(url: string, methods: HttpMethodType[], executer: Function, openapi?: object, allowPath?: boolean): void
  • canTriggerConfiguration(id: string, callback: function): boolean
  • cascadeDelete(obj: any, uuid: string): Promise<any>
  • computeParameters(): void
  • createIndex(): Promise<void>
  • delete(uid: any, sync?: boolean): Promise<void>
  • deleteItemFromCollection(uid: any, prop: any, index: any, itemWriteCondition: any, itemWriteConditionField: any): Promise<void>
  • emit(event: string | symbol, ...args: any[]): boolean
  • emitSync(event: any, data: any): Promise<any[]>
  • eventNames(): Array<string | symbol>
  • exists(uid: string): Promise<boolean>
  • find(request?: any, offset?: number, limit?: number): Promise<any>
  • generateUid(): any
  • get(uid: string, ctx?: Context): Promise<T>
  • getAll(list?: any): Promise<T[]>
  • getConfiguration(id: string): Promise<Map<string, any>>
  • getMapper(map: any, uuid: any): number
  • getMaxListeners(): number
  • getName(): string
  • getParameters(): K
  • getService<T>(service: string): T
  • getUrl(): string
  • getUuidField(): string
  • handleIndex(object: CoreModel, updates: object | string): Promise<void>
  • handleMap(object: any, map: any, updates: any): Promise<any[]>
  • httpAction(ctx: Context): Promise<void>
  • httpCreate(ctx: Context): Promise<void>
  • httpGet(ctx: Context): Promise<void>
  • httpGlobalAction(ctx: Context): Promise<void>
  • httpRoute(ctx: Context): Promise<void>
  • httpUpdate(ctx: Context): Promise<void>
  • incrementAttribute(uid: any, prop: any, value: any): Promise<void | any[]>
  • init(): Promise<void>
  • initMap(map: any): void
  • initModel(object: any): T
  • initRoutes(): void
  • isMapped(property: string): boolean
  • listenerCount(type: string | symbol): number
  • listeners(event: string | symbol): Function[]
  • off(event: string | symbol, listener: function): this
  • on(event: string | symbol, listener: function): this
  • onAsync(event: any, callback: any, queue?: string): void
  • Listen to an event as on(...) would do except that it will be asynchronous

    Parameters

    • event: any
    • callback: any
    • Default value queue: string = undefined

      Name of queue to use, can be undefined, queue name are used to define differents priorities

    Returns void

  • once(event: string | symbol, listener: function): this
  • patch(object: any, reverseMap?: boolean): Promise<any>
  • prependListener(event: string | symbol, listener: function): this
  • prependOnceListener(event: string | symbol, listener: function): this
  • rawListeners(event: string | symbol): Function[]
  • reinit(config: any): Promise<void>
  • removeAllListeners(event?: string | symbol): this
  • removeAttribute(uuid: string, attribute: string): Promise<void>
  • removeListener(event: string | symbol, listener: function): this
  • removeMapper(map: any, uuid: any): boolean
  • resolve(): void
  • save(object: any, ctx?: Context): Promise<any>
  • setMaxListeners(n: number): this
  • toPublicJSON(object: any): string
  • toString(): string
  • update(object: any, reverseMap?: boolean, partial?: boolean): Promise<any>
  • Update an object

    Parameters

    • object: any
    • Default value reverseMap: boolean = true

      internal use only, for disable map resolution

    • Default value partial: boolean = false

    Returns Promise<any>

    with saved object

  • upsertItemToCollection(uid: any, prop: any, item: any, index?: any, itemWriteCondition?: any, itemWriteConditionField?: any): Promise<void>
  • Parameters

    • uid: any
    • prop: any
    • item: any
    • Default value index: any = undefined
    • Default value itemWriteCondition: any = undefined
    • Default value itemWriteConditionField: any = undefined

    Returns Promise<void>

  • listenerCount(emitter: EventEmitter, event: string | symbol): number

Generated using TypeDoc