Functionality - Oppenjaimer/LbelDB.js GitHub Wiki

Functionality

LbelDB.js stores data in .lbel files (pretty much like text files) line by line, and allows you to work with them as long as they are in local memory.

Initialization

When the init function is called, two files are created (unless they exist already, in which case nothing changes): dbs.lbel and dat.lbel. The former is used for storing the labels (AKA column headers), while the latter is used for storing the row (or column) values.

Creating labels

After calling init, you should call create in order to create the labels. An id label is automatically created.

Columns

Columns can be created with the addC function. You only have to provide a label name when creating them, since each existing row is appended an empty string.

Updating columns

Columns can be updated with the updateC function.

Sorting out columns

You can sort out a column with the sortC function, which uses a natural sort algorithm.

Rows

Rows can be created with the addR function. An ID is automatically assigned to each row, right below the id label, starting the count at 10001.

Updating rows

You can either update an entire row with updateR, or update certain item in a row with updateRi.

Returning data by columns and rows

The returnC function returns columns from local memory, while the returnR function returns rows.

Deleting data

Data deletion from local memory can be done with either of the following functions: clearC for columns, clearR for rows or clearAll for all the data.

Storing and retrieving data

When storing the data from local memory in the files (store), they will be erased, meaning you will not be able to manipulate them until you get them back into local memory. This can be done with the retrieve function.

Note that all data are converted to string when stored, regardless of their actual type.

Visualizing data

In order to see the data in the form of a table, you can call the view function. Remember, local memory!