Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Mongo

Mongo Storage Adapter, keeps bBot brain data collections as sub-collection of a single parent Mongo DB model/collection. The memory sub-collection keeps the brain's in-memory data assigned against it's key (e.g. users). Long-term data is stored in sub-collections alongside memory, using either a key for key/value pairs, or a key-less array for serial data.

Hierarchy

Index

Constructors

constructor

  • new Mongo(bot: "/Volumes/x/code/amazebot/bbot/src/index"): Mongo
  • Create adapter instance with ref to bot instance. Prevent direct access to constructor for singleton adapter

    Parameters

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

    Returns Mongo

Properties

bot

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

The current bBot instance

model

model: Model<Document>

name

name: string = "mongo-storage-adapter"

Optional store

store: mongoose.Mongoose

Methods

find

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

findOne

  • findOne(sub: string, params: any): Promise<any>

keep

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

loadMemory

  • loadMemory(): Promise<any>

lose

  • lose(sub: string, params: any): 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

saveMemory

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

shutdown

  • shutdown(): Promise<void>

start

  • start(): Promise<void>

Static getInstance

  • getInstance(bot: "/Volumes/x/code/amazebot/bbot/src/index"): Mongo
  • Singleton instance init

    Parameters

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

    Returns Mongo

Object literals

config

config: object

autoIndex

autoIndex: boolean = true

keepAlive

keepAlive: number = 120

poolSize

poolSize: number = 10

reconnectInterval

reconnectInterval: number = 500

reconnectTries

reconnectTries: number = Number.MAX_VALUE

useNewUrlParser

useNewUrlParser: boolean = true

Generated using TypeDoc