A LevelDB implementation for indexing the messages and events stored in the DWN.

Constructors

Properties

db: LevelWrapper<string>

Methods

  • Deletes all of the index data associated with the item.

    Parameters

    Returns Promise<void>

  • Put an item into the index using information that will allow it to be queried for.

    Parameters

    • tenant: string
    • messageCid: string

      a unique ID that represents the item being indexed, this is also used as the cursor value in a query.

    • indexes: KeyValues

      (key-value pairs) to be included as part of indexing this item. Must include at least one indexing property.

    • Optionaloptions: IndexLevelOptions

      IndexLevelOptions that include an AbortSignal.

    Returns Promise<void>

  • Queries the index for items that match the filters. If no filters are provided, all items are returned.

    Parameters

    • tenant: string
    • filters: Filter[]

      Array of filters that are treated as an OR query.

    • queryOptions: QueryOptions

      query options for sort and pagination, requires at least sortProperty. The default sort direction is ascending.

    • Optionaloptions: IndexLevelOptions

      IndexLevelOptions that include an AbortSignal.

    Returns Promise<IndexedItem[]>

    an array of IndexedItem that match the given filters.

  • Queries the provided searchFilters asynchronously, returning results that match the matchFilters.

    Parameters

    Returns Promise<IndexedItem[]>

    if an invalid sort property is provided.

  • Queries the sort property index for items that match the filters. If no filters are provided, all items are returned. This query is a linear iterator over the sorted index, checking each item for a match. If a cursor is provided it starts the iteration from the cursor point.

    Parameters

    Returns Promise<IndexedItem[]>

  • Returns a PaginationCursor using the last item of a given array of IndexedItems. If the given array is empty, undefined is returned.

    Parameters

    Returns undefined | PaginationCursor

    if the sort property or cursor value is invalid.

  • Encodes a numerical value as a string for lexicographical comparison. If the number is positive it simply pads it with leading zeros. ex.: input: 1024 => "0000000000001024" input: -1024 => "!9007199254739967"

    Parameters

    • value: number

      the number to encode.

    Returns string

    a string representation of the number.

  • Encodes an indexed value to a string

    NOTE: we currently only use this for strings, numbers and booleans.

    Parameters

    • value: string | number | boolean

    Returns string