Members
errors
Predefined List of Errors to manipulate them all at one place.
reservedFieldNames
The following are reserved fields and filters that serve as 'keywords' and must not be used inside a row of a table in the database.
The reservedFilters are filters that the user can use for querying, refer to the querying docs for a guide on that.
unserialize
File ops coming soon.
Methods
createDatabase(dbName) → {undefined}
Creates a new database with dbName.
Doesn't allow overwriting the previously existing one.
Parameters:
| Name | Type | Description |
|---|---|---|
dbName |
string | The name of the database. |
Returns:
- Type
- undefined
generateUniqueId() → {Number}
Generates a unique id to be used in fields such as 'entryId'.
Returns:
A sufficiently random number that can be used as a unique Id.
- Type
- Number
getDatabase(dbName) → {string}
Gets the database with dbName.
Parameters:
| Name | Type | Description |
|---|---|---|
dbName |
string | The name of the database. |
Returns:
The serialized/stringified database data in localStorage.
- Type
- string
getNestedField(row, fieldToGet) → {any}
Function to get nested fields from objects, using strings like: 'parentField.childField'.
Parameters:
| Name | Type | Description |
|---|---|---|
row |
Object | The object representing a row in a database table. |
fieldToGet |
String | The string representation of the field to get from the database. |
Returns:
- Type
- any
rowMatchesFilters(row, filters) → {Boolean}
Checks whether a table row matches filters or not.
Parameters:
| Name | Type | Description |
|---|---|---|
row |
Object | The row to validate. |
filters |
Object | The filters to validate against. |
Returns:
- Type
- Boolean
validateValueAgainstFilter(filterValue, value) → {Boolean}
Function to validate value against a regex or just plain value.
Parameters:
| Name | Type | Description |
|---|---|---|
filterValue |
any | The value of the filter to validate against. |
value |
any | The value to check for equality. |
Returns:
- Type
- Boolean
verifyByCustomOperation(row, field, valueToValidateOn) → {Boolean}
Function to check if a row in a table matches a specified operation or not. (Operations such as in, not, not-in, includes, not includes etc).
Parameters:
| Name | Type | Description |
|---|---|---|
row |
Object | The object representing a row in a database table. |
field |
field | Name of field to verify operation on. |
valueToValidateOn |
* | The value to compare with, type depends on the operation. |
Returns:
- Type
- Boolean
verifyOrOperation(row, subFilters) → {Boolean}
Function to check if a row in a table matches any one of the specified operations or not. I.E: "Or" Operations.
Parameters:
| Name | Type | Description |
|---|---|---|
row |
Object | The object representing a row in a database table. |
subFilters |
Array | The filters to check the row against. |
Returns:
- Type
- Boolean
writeDatabase(dbName, databaseObject) → {undefined}
Serializes an object and writes it to a database in localStorage.
Parameters:
| Name | Type | Description |
|---|---|---|
dbName |
string | The name of the database to write to. |
databaseObject |
object | The object to serialize and write. |
Returns:
- Type
- undefined