Options
All
  • Public
  • Public/Protected
  • All
Menu

Class StorageAdapter

Storage adapter class, extended to connect brain with external storage provider. Methods are just raw endpoints to be extended.

Hierarchy

Index

Constructors

constructor

  • new StorageAdapter(bot: "/Volumes/x/code/amazebot/bbot/src/index"): StorageAdapter
  • Create an adapter instance. Adapter modules should provide a .use method that accepts the bot, to provide to their adapter class constructor, returning the instance.

    Parameters

    • bot: "/Volumes/x/code/amazebot/bbot/src/index"

      The current bBot instance

    Returns StorageAdapter

Properties

bot

bot: "/Volumes/x/code/amazebot/bbot/src/index"

The current bBot instance

name

name: string = "storage-adapter"

Methods

Abstract find

  • find(collection: string, params: any): Promise<any>

Abstract findOne

  • findOne(collection: string, params: any): Promise<any>
  • Query subset of collection from storage provider, returning single item

    Parameters

    • collection: string
    • params: any

    Returns Promise<any>

Abstract keep

  • keep(collection: string, data: any): Promise<void>

Abstract loadMemory

  • loadMemory(): Promise<any>

Abstract lose

  • lose(collection: string, params: any): Promise<void>
  • Remove anything from collection in storage that matches params

    Parameters

    • collection: string
    • params: any

    Returns Promise<void>

parseSchema

  • parseSchema(internal: any, schema: object, external?: any): any
  • Utility to convert internal object to schema required in adapter platform. Passing the original internal object as the external, allows inheriting all attributes without needing to map the ones that are the same in both. Otherwise, result would only include values from defined schema fields.

    Parameters

    • internal: any
    • schema: object
      • [path: string]: string
    • Default value external: any = {}

    Returns any

Abstract saveMemory

  • saveMemory(data: any): Promise<void>

Abstract shutdown

  • shutdown(): Promise<void>

Abstract start

  • start(): Promise<void>

Generated using TypeDoc