rex_nedb
Compare with rex_taffydb
- rex_taffydb is a synchronous in-memory database.
- rex_nedb is an asynchronous persistence or in-memory database.
Usage
Storage type
This plugin could store database into disk (persistence) or in memory.
This plugin could store database into disk (persistence) or in memory.
- Persistence: set "Database name" to a non-empty string and set the property "Storage" to "Disk".
- In memory: set property "Storage" to "In memory".
Write
Insert rows by CSV
Sample capx
Call "Action:Insert CSV data" to insert rows by CSV string.
Sample capx
Call "Action:Insert CSV data" to insert rows by CSV string.
- The first row of CSV is the name of fields,
- Other rows are data.
Data type
All data will be string type if "Eval mode" is "No".
Call "Action:Define type" to define a column to be number type. i.e. all values in that column are number. (sample capx)
All data will be string type if "Eval mode" is "No".
Call "Action:Define type" to define a column to be number type. i.e. all values in that column are number. (sample capx)
Eval mode
Set "Eval mode" to "Yes" could parse value by "eval" function of javascrpt. It could assign number, string value. (eval function could return object/array of course, but the "Expression:At" only could return number or string.) For example,
Set "Eval mode" to "Yes" could parse value by "eval" function of javascrpt. It could assign number, string value. (eval function could return object/array of course, but the "Expression:At" only could return number or string.) For example,
- number: 10
- string: 'hi'
- javascript function: Math.random() -- it return a number
Name,HP,MP
'aaa',100,20
'bbb',80,30
will insert 2 rows.
An error message will display on console while eval failed.
An error message will display on console while eval failed.
Insert rows by JSON
Sample capx
Call "Action:Insert JSON data" to insert rows by JSON string which exported by "Expression:AllRowsAsJSON", or "Expression:QueriedRowsAsJSON". These expressions will be described later.
Sample capx
Call "Action:Insert JSON data" to insert rows by JSON string which exported by "Expression:AllRowsAsJSON", or "Expression:QueriedRowsAsJSON". These expressions will be described later.
Callback
"Condition:On update" will be triggered when writing database success. Otherwise "Condition:On update error" will be triggered, get error message by "Expression:LastErrorMessage".
"Condition:On update" will be triggered when writing database success. Otherwise "Condition:On update error" will be triggered, get error message by "Expression:LastErrorMessage".
Insert a row
Sample capx
A row is composed by many key-value pairs. Follow these steps to insert 1 row-
1. First, prepare the row date by calling
2. Finally, call "Action:Save" to update or insert this prepared row.
Saved row ID could be read by "Expression:LastSavedRowID".
Sample capx
A row is composed by many key-value pairs. Follow these steps to insert 1 row-
1. First, prepare the row date by calling
- Action:Set value ( options: if greater , if less )
- Action:Set boolean value
- Action:Add to
2. Finally, call "Action:Save" to update or insert this prepared row.
Saved row ID could be read by "Expression:LastSavedRowID".
Update row by row ID
Uses "Action:Set row ID" to assign row ID while prepare data, then call "Action:Save" to update this row by this row ID. Insert a row if row ID had not found.
Uses "Action:Set row ID" to assign row ID while prepare data, then call "Action:Save" to update this row by this row ID. Insert a row if row ID had not found.
Index keys
Sample capx
There are 2 kinds of index keys-
Sample capx
There are 2 kinds of index keys-
- Unique index keys, a set of fields which the values are not repeated. Row could be indexed by these special keys.
- Index keys, to improve the performance when querying these keys.
Unique index keys and index keys could be set at property "Unique index keys" and "Index keys" , or set by "Action:Set index keys". Multiple keys are separated by ",". For example
Name
or
UID,VarName
Each saving ("Action:Save") will try to find row by index key first-
- If found, overwrite this row.
- If not found, insert a new row.
Reading by index keys will be described later section.
Callback
"Condition:On update" will be triggered when writing database success. Otherwise "Condition:On update error" will be triggered, get error message by "Expression:LastErrorMessage".
"Condition:On update" will be triggered when writing database success. Otherwise "Condition:On update error" will be triggered, get error message by "Expression:LastErrorMessage".
Remove row by row ID
Call "Action:Remove by row ID" to remove a row by row ID.
Call "Action:Remove by row ID" to remove a row by row ID.
Remove rows
Call "Action:Remove all" to remove all rows. i.e. clean this database to empty.
Call "Action:Remove all" to remove all rows. i.e. clean this database to empty.
Remove queried rows
Call "Action:Remove queried rows" to remove queried rows. Querying will be described later.
Call "Action:Remove queried rows" to remove queried rows. Querying will be described later.
Callback
"Condition:On remove rows" will be triggered when writing database success. Otherwise "Condition:On remove rows error" will be triggered, get error message by "Expression:LastErrorMessage".
"Condition:On remove rows" will be triggered when writing database success. Otherwise "Condition:On remove rows error" will be triggered, get error message by "Expression:LastErrorMessage".
Querying
Sample capx
Querying is used to get rows by some conditions/filters. Follow these steps to build a query filter for read rows or update these rows, or remove them.
Sample capx
Querying is used to get rows by some conditions/filters. Follow these steps to build a query filter for read rows or update these rows, or remove them.
1. create a new filter
Call "Action:1. New" to create a new filter start from all rows in database.
If querying does not have "Action:1. New" or "Condition:1. New", it will start from current queried rows (sample capx)
Call "Action:1. New" to create a new filter start from all rows in database.
If querying does not have "Action:1. New" or "Condition:1. New", it will start from current queried rows (sample capx)
2. add conditions
Then call
Then call
- "Action:2. value compare", or
- "Action:2. boolean value compare", or
- "Action:2. regex matched'
3. set order
Call "Action:3. order" to sort the queried rows if necessary.
Call "Action:3. order" to sort the queried rows if necessary.
It will get all rows if there has no condition assigned.
Load
Call "Action:Load queried rows" to load queried rows.
Call "Action:Load queried rows" to load queried rows.
Callback
"Condition:On load rows" will be triggered when loading rows success, get loaded rows in JSON string by "Expression:QueriedRowsAsJSON".
Otherwise "Condition:On load rows error" will be triggered, get error message by "Expression:LastErrorMessage".
"Condition:On load rows" will be triggered when loading rows success, get loaded rows in JSON string by "Expression:QueriedRowsAsJSON".
Otherwise "Condition:On load rows error" will be triggered, get error message by "Expression:LastErrorMessage".
Retrieve queried rows
Sample capx
Retrieving each queried row by "Condition:For each row". Get the content of each retrieved row by "Expression:CurRowContent", and index of this row by "Expression:CurRowIndex".
There are 3 formats to use "Expression:CurRowContent".
Sample capx
Retrieving each queried row by "Condition:For each row". Get the content of each retrieved row by "Expression:CurRowContent", and index of this row by "Expression:CurRowIndex".
There are 3 formats to use "Expression:CurRowContent".
- "Expression:CurRowContent" without any parameter, will return key-value pairs of current item in JSON string.
- "Expression:CurRowContent( key )" , will return the value of a specific key, or return 0 if the key does not exist.
- "Expression:CurRowContent( key, default_value )" , will return the value of a specific key, or return default value if the key does not exist.
These related expressions are the properties of queried rows
- "Expression:QueriedRowsCount", get current queried rows count.
- "Expression:QueriedSum( key )", get sum in current queried rows of a key.
- "Expression:QueriedMin( key )", get min in current queried rows of a key.
- "Expression:QueriedMax( key )", get max in current queried rows of a key.
Indexes of queried rows
Sample capx
Queried rows could be indexed by row index from 0 to rows count -1. (rows count = "Expression:QueriedRowsCount")
Sample capx
Queried rows could be indexed by row index from 0 to rows count -1. (rows count = "Expression:QueriedRowsCount")
Read value
Value in each row could be read by "Expression:Index2QueriedRowContent". It also has 3 formats.
Value in each row could be read by "Expression:Index2QueriedRowContent". It also has 3 formats.
- "Expression:Index2QueriedRowContent( index )", will return key-value pairs of current item in JSON string.
- "Expression:Index2QueriedRowContent( index, key )" , will return the value of a specific key, or return 0 if the key does not exist.
- "Expression:Index2QueriedRowContent( index, key, default_value )" , will return the value of a specific key, or return default value if the key does not exist.
Set value
Call "Action:Set row index" to set row ID by this row index. Insert a row if row ID had not found.
Call "Action:Set row index" to set row ID by this row index. Insert a row if row ID had not found.
Remove row
A queried row could be removed by "Action:Remove by row index".
A queried row could be removed by "Action:Remove by row index".
Database reference
Sample capx
"Database name" in properties table is the global name of database.
Set it to "" will make it to be a private database which will be destroyed while this instance had been destroyed.
If this database name is not "". It will reference to a global database, instances with the same "Database name" will reference to the same database. In this way, user could separate writing and reading into different database instance.
Sample capx
"Database name" in properties table is the global name of database.
Set it to "" will make it to be a private database which will be destroyed while this instance had been destroyed.
If this database name is not "". It will reference to a global database, instances with the same "Database name" will reference to the same database. In this way, user could separate writing and reading into different database instance.
Save & load
It supports official saving & loading feature when using "Disk" storage mode, queried rows will also be saved.
It supports official saving & loading feature when using "Disk" storage mode, queried rows will also be saved.
Debug panel
All rows will be shown at debug panel in JSON format.
All rows will be shown at debug panel in JSON format.