FileDB.js

.table()

Load/create/get table

Syntax

var T = myDB.table(tableName[, tableColumns, tableOptions][, tableCallback]);

tableColumns = {
    columnName: columnOptions,
    columnName: columnOptions,
    columnName: columnOptions,
    ...
}

// all options are optional
columnOptions = {

    // defines a value type restriction
    typeof: "string" | "number" | "boolean"

    // defines if the value can be null/undefined
    null: true | false

    // sets a callback function to get default value if it's null
    default: function () {
        return defaultValue;
    }
}

// all options are optional
tableOptions = {

    // specifies AI for a single column
    autoIncrement: ["columnName", currentValue]

    // defines unique column ranges
    unique: [
        ["columnName1a", "columnName1b", "columnName1c", ...],
        ["columnName2a", "columnName2b", "columnName2c", ...],
        ["columnName3n", ...],
        ...
    ]

    // sets column references
    references: {
        columnName: "refTableName.refColumnName",
        columnName: "refTableName.refColumnName",
        columnName: "refTableName.refColumnName",
        ...
    }
}