rex_taffydb
Usage
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.
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
Index keys are a set of fields which the values are not repeated. Row could be indexed by these special keys.
Index keys could be set at "Index keys" in properties table, or by "Action:Set index keys". And multiple keys are separated by ",". For example
Sample capx
Index keys are a set of fields which the values are not repeated. Row could be indexed by these special keys.
Index keys could be set at "Index keys" in properties table, or by "Action:Set index keys". And 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.
Index keys also affects the result of inserting by CSV string.
Reading by index keys will be described later section.
Update rows
Sample capx
Call "Action:Update value" or "Action:Update boolean value" to update queried rows. Querying will be described later.
It could be used to append a new key for all rows.
Sample capx
Call "Action:Update value" or "Action:Update boolean value" to update queried rows. Querying will be described later.
It could be used to append a new key for all rows.
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
Sample capx
Call "Action:Remove queried rows" to remove queried rows. Querying will be described later.
Sample capx
Call "Action:Remove queried rows" to remove queried rows. Querying will be described later.
Read
Read all rows
Get all rows in JSON format by "Expression:AllRowsAsJSON", or get the count of all rows by "Expression:AllRowsCount".
Get all rows in JSON format by "Expression:AllRowsAsJSON", or get the count of all rows by "Expression:AllRowsCount".
Read by index keys
Sample capx
Since a row could be retrieved by index keys. Value of a specific field in this row could be read by "Expression:At". There are 2 formats in this expression.
Sample capx
Since a row could be retrieved by index keys. Value of a specific field in this row could be read by "Expression:At". There are 2 formats in this expression.
- "Expression:At( valueOfIndexKey0, valueOfIndexKey1, valueOfIndexKey2, .... , dataKey )", it first gets row by index keys with (valueOfIndexKey0, valueOfIndexKey1, valueOfIndexKey2, .... ) , then gets the value of dataKey, or returns 0 if the key does not exist.
- "Expression:At( valueOfIndexKey0, valueOfIndexKey1, valueOfIndexKey2, .... , dataKey, defaultValue )", it first gets row by index keys with (valueOfIndexKey0, valueOfIndexKey1, valueOfIndexKey2, .... ) , then gets the value of dataKey. Returns defaultValue if the target value is not found. (Maybe the row is not existed, or the dataKey is not existed.)
In the sample capx, the index keys are set to "Name" in properties table. And the reading expression is
DB.At("aaa", "HP")
It will first find the row by "Name" is equal to "aaa", then return the value of key "HP".
User might find that, single index key is almost the same with rex_CSV plugin.
Here is another sample capx which implement a counter in a row.
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
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", or
- "Condition:1. New"
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', or
- "Condition:2. value compare", or
- "Condition:2. boolean value compare", or
- "Condition:2. regex matched"
3. set order
Call
Call
- "Action:3. order", or
- "Condition:3. order"
It will get all rows if there has no condition assigned.
Get queried rows by "Expression:QueriedRowsAsJSON".
Get queried rows by "Expression:QueriedRowsAsJSON".
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.
Queried result after database updated
Sample capx
The queried result is not constant. Queried result will be changed after database updated.
Sample capx
The queried result is not constant. Queried result will be changed after database updated.
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, queried result will also be saved.
It supports official saving & loading feature, queried result 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.