Options
All
  • Public
  • Public/Protected
  • All
Menu

Module @textile/threads-database

Threads Database (threads-database)

Client-side database built on Textile's Threads protocol

Textile License npm (scoped)

This sub-package is part of js-threads. See the top-level documentation for details.

Index

References

Collection

Re-exports Collection

Config

Re-exports Config

Database

Re-exports Database

DatabaseSettings

Re-exports DatabaseSettings

Document

Re-exports Document

FilterQuery

Re-exports FilterQuery

JSONSchema

Re-exports JSONSchema

Options

Re-exports Options

ReadonlyCollection

Re-exports ReadonlyCollection

Result

Re-exports Result

StartOptions

Re-exports StartOptions

existingKeyError

Re-exports existingKeyError

mismatchError

Re-exports mismatchError

missingIdentity

Re-exports missingIdentity

resolve

Re-exports resolve

Type aliases

BSONTypeAlias

BSONTypeAlias: "number" | "double" | "string" | "object" | "array" | "binData" | "undefined" | "objectId" | "bool" | "date" | "null" | "regex" | "dbPointer" | "javascript" | "symbol" | "javascriptWithScope" | "int" | "timestamp" | "long" | "decimal" | "minKey" | "maxKey"

Condition

Type parameters

  • T

EventJob

EventJob<T>: { body: T; id: Buffer }

Type parameters

  • T

Type declaration

  • body: T
  • id: Buffer

Events

Events: { record: (rec: ThreadRecord) => void }

Type declaration

  • record: (rec: ThreadRecord) => void
      • (rec: ThreadRecord): void
      • Parameters

        • rec: ThreadRecord

        Returns void

FilterQuery

FilterQuery<T>: {} & RootQuerySelector<T>

Type parameters

  • T

JSONSchema

JSONSchema: JSONSchema4 | JSONSchema6 | JSONSchema7

MongoAltQuery

MongoAltQuery<T>: T extends Array<infer U> ? T | RegExpForString<U> : RegExpForString<T>

Type parameters

  • T

ObjectQuerySelector

ObjectQuerySelector<T>: T extends Record<string, unknown> ? {} : QuerySelector<T>

Type parameters

  • T

QuerySelector

QuerySelector<T>: { $all?: T extends Array<infer U> ? any[] : never; $elemMatch?: T extends Array<infer U> ? Record<string, unknown> : never; $eq?: T; $exists?: undefined | false | true; $expr?: any; $gt?: T; $gte?: T; $in?: T[]; $jsonSchema?: any; $lt?: T; $lte?: T; $mod?: T extends number ? [number, number] : never; $ne?: T; $nin?: T[]; $not?: T extends string ? QuerySelector<T> | RegExp : QuerySelector<T>; $options?: T extends string ? string : never; $regex?: T extends string ? RegExp | string : never; $size?: T extends Array<infer U> ? number : never; $type?: BSONType | BSONTypeAlias }

Type parameters

  • T

Type declaration

  • Optional $all?: T extends Array<infer U> ? any[] : never
  • Optional $elemMatch?: T extends Array<infer U> ? Record<string, unknown> : never
  • Optional $eq?: T
  • Optional $exists?: undefined | false | true

    When true, $exists matches the documents that contain the field, including documents where the field value is null.

  • Optional $expr?: any
  • Optional $gt?: T
  • Optional $gte?: T
  • Optional $in?: T[]
  • Optional $jsonSchema?: any
  • Optional $lt?: T
  • Optional $lte?: T
  • Optional $mod?: T extends number ? [number, number] : never
  • Optional $ne?: T
  • Optional $nin?: T[]
  • Optional $not?: T extends string ? QuerySelector<T> | RegExp : QuerySelector<T>
  • Optional $options?: T extends string ? string : never
  • Optional $regex?: T extends string ? RegExp | string : never
  • Optional $size?: T extends Array<infer U> ? number : never
  • Optional $type?: BSONType | BSONTypeAlias

RegExpForString

RegExpForString<T>: T extends string ? RegExp | T : T

Type parameters

  • T

RootQuerySelector

RootQuerySelector<T>: { $and?: Array<FilterQuery<T>>; $comment?: undefined | string; $nor?: Array<FilterQuery<T>>; $or?: Array<FilterQuery<T>>; $text?: undefined | { $caseSensitive?: undefined | false | true; $diacraticSensitive?: undefined | false | true; $language?: undefined | string; $search: string }; $where?: string | ((...args: any[]) => any) }

Type parameters

  • T

Type declaration

Variables

Const existingKeyError

existingKeyError: Error = new Error("Existing key")

Const mismatchError

mismatchError: Error = new Error("Input ThreadID does not match existing database ThreadID. Consider creating new database or use a matching ThreadID.")

Const missingIdentity

missingIdentity: Error = new Error("Identity required. You may use Database.randomIdentity() to generate a new one, but see caveats in docs.")

Functions

Cache

  • Cache(params?: CacheOptions): (_target: any, _propertyKey: string | symbol, descriptor: PropertyDescriptor) => void
  • Parameters

    Returns (_target: any, _propertyKey: string | symbol, descriptor: PropertyDescriptor) => void

      • (_target: any, _propertyKey: string | symbol, descriptor: PropertyDescriptor): void
      • Parameters

        • _target: any
        • _propertyKey: string | symbol
        • descriptor: PropertyDescriptor

        Returns void

createThread

  • createThread(network: Network, id?: ThreadID, key?: PrivateKey | PublicKey): Promise<ThreadInfo>
  • Parameters

    • network: Network
    • Default value id: ThreadID = ThreadID.fromRandom(ThreadID.Variant.Raw, 32)
    • Optional key: PrivateKey | PublicKey

    Returns Promise<ThreadInfo>

decodeRecord

  • decodeRecord<T>(rec: ThreadRecord, info: ThreadInfo): Promise<undefined | T>
  • Type parameters

    • T

    Parameters

    • rec: ThreadRecord
    • info: ThreadInfo

    Returns Promise<undefined | T>

maybeLocalAddr

  • maybeLocalAddr(ip: string): boolean | RegExpMatchArray

Const resolve

  • resolve(object: any, path: string, defaultValue?: any): any

threadAddr