Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DBCollection

Class for creating collections of structured documents

Hierarchy

  • DBCollection

Index

Constructors

Properties

Other Methods

Query Methods

Constructors

constructor

  • Create a structured collection of documents

    Parameters

    • db: DB

      Database reference

    • schema: SchemaTemplateType

      Schema for content to adhere to

    Returns DBCollection

Properties

Readonly col_

col_: Debugger

Debugger variable

Readonly db

db: DB

Reference to the DB object

docs

docs: DBDoc[]

Document array

Readonly name

name: string

Name of the collection

reactiveIndexed

reactiveIndexed: Map<Query[] | QueryBuilder, { docs: DBDoc[] }> = ...

Map for reactive query results

Readonly schema

schema: {}

Schema every document should adhere to

Type declaration

  • [key: string]: any

Other Methods

emitEvent

  • emitEvent(event: MemsDBEvent): void
  • Emit an event to the attached database

    Parameters

    • event: MemsDBEvent

      Event to emit

    Returns void

id

  • id(idStr: string): undefined | DBDoc
  • Find a specific document by its id

    Parameters

    • idStr: string

      ID to filter by

    Returns undefined | DBDoc

insert

  • insert(opts: CollectionInsertOpts): DBDoc
  • Alias of insertOne

    Parameters

    • opts: CollectionInsertOpts

      Insert document options

    Returns DBDoc

insertMany

insertOne

  • insertOne(opts: CollectionInsertOpts): DBDoc
  • Insert a new document into the array. Defaults will be loaded from the schema

    Parameters

    • opts: CollectionInsertOpts

      Insert document options

    Returns DBDoc

toJSON

  • toJSON(): string
  • Custom handler for toJSON to avoid recursion of toString and toJSON

    Returns string

toString

  • toString(): string
  • Custom handler for toString to avoid recursion of toString and toJSON

    Returns string

Query Methods

find

  • find(opts?: CollectionFindOpts): DBDoc[]
  • Run a set of queries to filter documents

    Parameters

    • opts: CollectionFindOpts = ...

    Returns DBDoc[]

Generated using TypeDoc