### Hierarchy

- _NanoSQL_Storage

## Index

### Constructors

- constructor

### Properties

- _activeTransactions
- _doHistory
- _historyArray
- _historyLength
- _historyMode
- _historyPoint
- _historyPointIndex
- _indexedDB
- _levelDBs
- _mode
- _models
- _parent
- _persistent
- _savedArgs
- _storeMemory
- _tables
- _transactionData
- _utilityTable

### Methods

- _addHistoryPoint
- _addHistoryRow
- _clear
- _delete
- _execTransaction
- _generateID
- _newTable
- _read
- _readArray
- _readRange
- _rebuildSecondaryIndex
- _rebuildTries
- _updateSecondaryIndex
- _upsert
- _utility
- init

## Constructors

### constructor

- new _NanoSQL_Storage(database: _NanoSQLDB, args: DBConnect): _NanoSQL_Storage

- - Defined in db-storage.ts:235

  #### Parameters

  - ##### database: _NanoSQLDB

  - ##### args: DBConnect

  #### Returns _NanoSQL_Storage

## Properties

### _activeTransactions

_activeTransactions: number[]

- Defined in db-storage.ts:150

Store current, active transaction information.

type

  {number[]}

memberof

  _NanoSQL_Storage

### _doHistory

_doHistory: boolean

- Defined in db-storage.ts:166

Flag to store wether history is enabled or not.

type

  {boolean}

memberof

  _NanoSQLDB

### _historyArray

_historyArray: Array<number>

- Defined in db-storage.ts:142

A variable to hold the state of the history pointer and history length

internal
type

  {Array<number>}

memberof

  _NanoSQLDB

### _historyLength

_historyLength: number

- Defined in db-storage.ts:133

Keeps track of how many total history points we have

type

  {number}

memberof

  _NanoSQLDB

### _historyMode

_historyMode: 1 | 2

- Defined in db-storage.ts:176

The current history mode, linear (standard) or parallel. (mode 1) Linear mode records evey change in the databse as a timeline. (mode 2) Parallel mode creates a linear history for every row, recording revisions to the row.

type

  {("lin"|"par")}

memberof

  _NanoSQL_Storage

### _historyPoint

_historyPoint: number

- Defined in db-storage.ts:125

The pointer that indiciates where in history to pull from.

internal
type

  {number}

memberof

  _NanoSQLDB

### _historyPointIndex

_historyPointIndex: object

- Defined in db-storage.ts:114

Since multiple rows might be inside a single history point, this keeps track of which history points are attached to which history point rows for fast seeking.

type

  {{ [historyPoint: number]: number[]; // History Row IDs }}

memberof

  _NanoSQL_Storage

#### Type declaration

- ##### [historyPoint: number]: number[]

### _indexedDB

_indexedDB: IDBDatabase

- Defined in db-storage.ts:22

### _levelDBs

_levelDBs: object

- Defined in db-storage.ts:202

Level Up store variable.

type

  {{

          [key: string]: any;
      }}

memberof

  _NanoSQL_Storage

#### Type declaration

- ##### [key: string]: any

### _mode

_mode: any

- Defined in db-storage.ts:20

### _models

_models: object

- Defined in db-storage.ts:35

Stores a row index for each table.

internal
type

  {{ [tableHash: number]: Array<DataModel>; }}

memberof

  _NanoSQLDB

#### Type declaration

- ##### [tableHash: number]: Array<DataModel>

### _parent

_parent: _NanoSQLDB

- Defined in db-storage.ts:24

### _persistent

_persistent: boolean

- Defined in db-storage.ts:158

Wether to enable the persistent storage system or not.

type

  {boolean}

memberof

  _NanoSQLDB

### _savedArgs

_savedArgs: DBConnect

- Defined in db-storage.ts:192

Save the connect args so we can re init the store on command.

type

  {DBConnect}

memberof

  _NanoSQL_Storage

### _storeMemory

_storeMemory: boolean

- Defined in db-storage.ts:184

Flag to store wether tables are stored in memory or not.

type

  {boolean}

memberof

  _NanoSQLDB

### _tables

_tables: object

- Defined in db-storage.ts:58

Utility data for each table, including holding the primary key, name, incriment number and primary keys

type

  {{

          [tableHash: number]: {
              _pk: string // Table primary key
              _pkType: string; // Primary key data type
              _name: string // Table name
              _incriment: number; // Table incriment counter
              _index: string[]; // The table index of row IDs in this table
              _keys: string[]; // Array of column keys
              _defaults: any[]; // Array of column defaults
              _rows: { // If memory mode is enabled, row data is stored here.
                  [key: string]: DBRow
              }
          }
      }}

memberof

  _NanoSQL_Storage

#### Type declaration

- ##### [tableHash: number]: object

  - ##### _defaults: any[]

  - ##### _incriment: number

  - ##### _index: (string | number)[]

  - ##### _keys: string[]

  - ##### _name: string

  - ##### _pk: string

  - ##### _pkType: string

  - ##### _relations: object[]

    - ##### _key: string

    - ##### _mapTo: string

    - ##### _table: string

    - ##### _type: "array" | "single"

  - ##### _rows: object

    - ##### [key: string]: DBRow | null

  - ##### _secondaryIndexes: string[]

  - ##### _trieColumns: string[]

  - ##### _trieIndex: Trie

  - ##### _trieObjects: object

    - ##### [column: string]: Trie

### _transactionData

_transactionData: object

- Defined in db-storage.ts:218

Tracks transaction data in memory to commit to the data store when the transaction ends.

type

  {({

          [tableName: string]:    {
              type: string;
              key: string|number;
              value: string;
          }[]
      })}

memberof

  _NanoSQL_Storage

#### Type declaration

- ##### [transactionID: number]: object

  - ##### [tableName: string]: object[]

    - ##### key: string | number

    - ##### type: string

    - ##### value: string

### _utilityTable

_utilityTable: object

- Defined in db-storage.ts:98

Utility table to store misc data.

This is populated regardless of the memory db setting.

type

  {{

          [key: string]: {
              key: string,
              value: any;
          }
      }}

memberof

  _NanoSQL_Storage

#### Type declaration

- ##### [key: string]: object

  - ##### key: string

  - ##### value: any

## Methods

### _addHistoryPoint

- _addHistoryPoint(tableID: number, updatedPKs: any[], describe: string, complete: function): void

- - Defined in db-storage.ts:1103

  Add a new history record to the system.

  memberof

    _NanoSQL_Storage

  #### Parameters

  - ##### tableID: number

  - ##### updatedPKs: any[]

  - ##### describe: string

  - ##### complete: function

    - - (): void

      - #### Returns void

### _addHistoryRow

- _addHistoryRow(tableID: number, rowData: DBRow, transactionID: number, complete: function): void

- - Defined in db-storage.ts:1079

  Add a record of the previous row data to the history system.

  memberof

    _NanoSQL_Storage

  #### Parameters

  - ##### tableID: number

  - ##### rowData: DBRow

  - ##### transactionID: number

  - ##### complete: function

    - - (rowID: number): void

      - #### Parameters

        - ##### rowID: number

        #### Returns void

### _clear

- _clear(type: "all" | "hist", complete: Function): void

- - Defined in db-storage.ts:828

  Clears everything from the data store.

  memberof

    _NanoSQL_Storage

  #### Parameters

  - ##### type: "all" | "hist"

  - ##### complete: Function

  #### Returns void

### _delete

- _delete(tableName: string, rowID: string | number, callBack?: undefined | function, transactionID?: undefined | number): void

- - Defined in db-storage.ts:897

  Removes rows from the store.

  memberof

    _NanoSQL_Storage

  #### Parameters

  - ##### tableName: string

  - ##### rowID: string | number

  - ##### Optional callBack: undefined | function

  - ##### Optional transactionID: undefined | number

  #### Returns void

### _execTransaction

- _execTransaction(transactionID: number): Promise<any[]>

- - Defined in db-storage.ts:786

  Complets a transaction.

  memberof

    _NanoSQL_Storage

  #### Parameters

  - ##### transactionID: number

  #### Returns Promise<any[]>

### _generateID

- _generateID(type: string, tableHash: number): string | number

- - Defined in db-storage.ts:1193

  Generate a row ID given the type of ID needed and the row incriment value.

  memberof

    _NanoSQL_Storage

  #### Parameters

  - ##### type: string

  - ##### tableHash: number

  #### Returns string | number

### _newTable

- _newTable(tableName: string, dataModels: DataModel[]): string

- - Defined in db-storage.ts:1611

  Setup a new table.

  memberof

    _NanoSQL_Storage

  #### Parameters

  - ##### tableName: string

  - ##### dataModels: DataModel[]

  #### Returns string

### _read

- _read(tableName: string, row: string | number | Function, callBack: function, readIndex?: undefined | true | false): void

- - Defined in db-storage.ts:1478

  Simple read from the database store.

  You can either pass in a primary key or a function for the row. If a function is passed in, that function is called for every row to allow filtering. You can also pass in the string "all" to just read every row.

  memberof

    _NanoSQL_Storage

  #### Parameters

  - ##### tableName: string

  - ##### row: string | number | Function

  - ##### callBack: function

    - - (rows: any[]): void

      - #### Parameters

        - ##### rows: any[]

        #### Returns void

  - ##### Optional readIndex: undefined | true | false

  #### Returns void

### _readArray

- _readArray(tableName: string, pkArray: any[], callBack: function): void

- - Defined in db-storage.ts:1366

  Read an array of rows from a given database by an array of primary keys.

  memberof

    _NanoSQL_Storage

  #### Parameters

  - ##### tableName: string

  - ##### pkArray: any[]

  - ##### callBack: function

    - - (rows: DBRow[]): void

      - #### Parameters

        - ##### rows: DBRow[]

        #### Returns void

### _readRange

- _readRange(tableName: string, key: string, between: any[], callBack: function): void

- - Defined in db-storage.ts:1395

  IndexedDB and LevelDB both have optimizations for reading a range of primary keys, this method takes advantage of those optimizations.

  memberof

    _NanoSQL_Storage

  #### Parameters

  - ##### tableName: string

  - ##### key: string

  - ##### between: any[]

  - ##### callBack: function

    - - (rows: DBRow[]): void

      - #### Parameters

        - ##### rows: DBRow[]

        #### Returns void

### _rebuildSecondaryIndex

- _rebuildSecondaryIndex(tableName: string, complete: function): void

- - Defined in db-storage.ts:685

  #### Parameters

  - ##### tableName: string

  - ##### complete: function

    - - (): void

      - #### Returns void

### _rebuildTries

- _rebuildTries(callBack: Function): void

- - Defined in db-storage.ts:738

  Rebuild Trie structures on secondary indexes

  memberof

    _NanoSQL_Storage

  #### Parameters

  - ##### callBack: Function

  #### Returns void

### _updateSecondaryIndex

- _updateSecondaryIndex(newRow: DBRow, tableID: number, callBack?: undefined | function): void

- - Defined in db-storage.ts:980

  Update the secondary attached to a specific row and table.

  memberof

    _NanoSQL_Storage

  #### Parameters

  - ##### newRow: DBRow

  - ##### tableID: number

  - ##### Optional callBack: undefined | function

  #### Returns void

### _upsert

- _upsert(tableName: string, rowID: string | number | null, rowData: any, callBack?: undefined | function, transactionID?: undefined | number): void

- - Defined in db-storage.ts:1214

  Inserts data into the store.

  memberof

    _NanoSQL_Storage

  #### Parameters

  - ##### tableName: string

  - ##### rowID: string | number | null

  - ##### rowData: any

  - ##### Optional callBack: undefined | function

  - ##### Optional transactionID: undefined | number

  #### Returns void

### _utility

- _utility(type: "r" | "w", key: string, value?: any): any

- - Defined in db-storage.ts:1584

  Write or access utility options.

  memberof

    _NanoSQLDB

  #### Parameters

  - ##### type: "r" | "w"

  - ##### key: string

  - ##### Optional value: any

  #### Returns any

### init

- init(database: _NanoSQLDB, args: DBConnect): void

- - Defined in db-storage.ts:252

  Setup persistent storage engine and import any existing data into memory.

  static
  memberof

    _NanoSQL_Persistent

  #### Parameters

  - ##### database: _NanoSQLDB

  - ##### args: DBConnect

  #### Returns void

Generated using TypeDoc