Class: RBT

db.RBT

new RBT(locationnullable, optionsnullable)

An iterative red black tree. Many of its options, parameters, and methods mimic the leveldown interface.

Parameters:
Name Type Attributes Description
location String <nullable>

Phony location.

options Object <nullable>
Properties
Name Type Description
compare function

Comparator.

Source:

Methods

(static) destroy(location) → {Promise}

Destroy the database (leveldown function) (NOP).

Parameters:
Name Type Description
location String
Source:
Returns:
Type
Promise

(static) repair(location) → {Promise}

Repair the database (leveldown function) (NOP).

Parameters:
Name Type Description
location String
Source:
Returns:
Type
Promise

approximateSize(start, end) → {Promise}

Calculate approximate database size (leveldown method).

Parameters:
Name Type Description
start Buffer | String

Start key.

end Buffer | String

End key.

Source:
Returns:
  • Returns Number.
Type
Promise

batch(opsnullable, optionsnullable) → {Promise|Leveldown.Batch}

Create an atomic batch (leveldown method).

Parameters:
Name Type Attributes Description
ops Array:.<Object:> <nullable>
options Object <nullable>
Source:
See:
  • Leveldown.Batch
Returns:
  • Type
    Promise
  • Type
    Leveldown.Batch

close() → {Promise}

Close the database (leveldown method).

Source:
Returns:
Type
Promise

del(key, optionsnullable) → {Promise}

Remove a record (leveldown method).

Parameters:
Name Type Attributes Description
key Buffer | String
options Object <nullable>
Source:
Returns:
Type
Promise

dump() → {Array:.<RBTNode:>}

Dump all records.

Source:
Returns:

Records.

Type
Array:.<RBTNode:>

get(key, optionsnullable) → {Promise}

Retrieve a record (leveldown method).

Parameters:
Name Type Attributes Description
key Buffer | String
options Object <nullable>
Source:
Returns:
  • Returns Buffer.
Type
Promise

getProperty(name) → {String}

Get a database property (leveldown method) (NOP).

Parameters:
Name Type Description
name String

Property name.

Source:
Returns:
Type
String

insert(key, value)

Insert a record.

Parameters:
Name Type Description
key Buffer | String
value Buffer
Source:

(private) insertFixup(x)

Repaint necessary nodes after insertion.

Parameters:
Name Type Description
x RBTNode
Source:

iterator(options) → {Leveldown.Iterator}

Create an iterator (leveldown method).

Parameters:
Name Type Description
options Object

See {Leveldown.Iterator}.

Source:
Returns:

.

Type
Leveldown.Iterator

(private) max(z) → {RBTNode}

Maximum subtree.

Parameters:
Name Type Description
z RBTNode
Source:
Returns:
Type
RBTNode

(private) min(z) → {RBTNode}

Minimum subtree.

Parameters:
Name Type Description
z RBTNode
Source:
Returns:
Type
RBTNode

open(optionsnullable) → {Promise}

Open the database (leveldown method).

Parameters:
Name Type Attributes Description
options Object <nullable>
Source:
Returns:
Type
Promise

(private) predecessor(x) → {RBTNode}

Predecessor node.

Parameters:
Name Type Description
x RBTNode
Source:
Returns:
Type
RBTNode

put(key, value, optionsnullable) → {Promise}

Insert a record (leveldown method).

Parameters:
Name Type Attributes Description
key Buffer | String
value Buffer
options Object <nullable>
Source:
Returns:
Type
Promise

range(gte, lte) → {Array:.<RBTNode:>}

Traverse between a range of keys and collect records.

Parameters:
Name Type Description
gte Buffer
lte Buffer
Source:
Returns:

Records.

Type
Array:.<RBTNode:>

remove(key) → {Boolean}

Remove a record.

Parameters:
Name Type Description
key Buffer | String
Source:
Returns:
Type
Boolean

(private) removeFixup(x)

Repaint necessary nodes after removal.

Parameters:
Name Type Description
x RBTNode
Source:

(private) removeNode(z)

Remove a single node.

Parameters:
Name Type Description
z RBTNode
Source:

(private) rotl(x)

Do a left rotate.

Parameters:
Name Type Description
x RBTNode
Source:

(private) rotr(x)

Do a right rotate.

Parameters:
Name Type Description
x RBTNode
Source:

Do a key lookup.

Parameters:
Name Type Description
key Buffer | String
Source:
Returns:

value

Type
Buffer

snapshot() → {RBTNode}

Take a snapshot and return a cloned root node.

Source:
Returns:
Type
RBTNode

(private) successor(x) → {RBTNode}

Successor node.

Parameters:
Name Type Description
x RBTNode
Source:
Returns:
Type
RBTNode

traverse(test) → {Array:.<RBTNode:>}

Traverse the key and filter records.

Parameters:
Name Type Description
test function
Source:
Returns:

Records.

Type
Array:.<RBTNode:>