rex_backendless_itemtable
Introduction
Items table indexed by (itemID, key), supports writing an item or reading items back.
Items table indexed by (itemID, key), supports writing an item or reading items back.
Class name
"Class name" in properties table is the "table name" shown at dashboard.
"Class name" in properties table is the "table name" shown at dashboard.
Write an item
Sample capx
Sample capx
Prepare
Before write an item, it needs prepare this item first by these actions -
Before write an item, it needs prepare this item first by these actions -
- Action:Set value,
- Action:Set boolean value
- Action:Set itemID ( objectId )
Write
Then call "Action:Save" to save prepared item. Server will append a new item if itemID had not be assigned by "Action:Set itemID".
"Condition:On save" would be triggered when saving this item successful, otherwise "Condition:On save error" will be triggered. Get object ID of saved item by "expression:LastSavedItemID".
Then call "Action:Save" to save prepared item. Server will append a new item if itemID had not be assigned by "Action:Set itemID".
"Condition:On save" would be triggered when saving this item successful, otherwise "Condition:On save error" will be triggered. Get object ID of saved item by "expression:LastSavedItemID".
Primary key
Set parameter "Key type" to "primary key" in "Action:Set value", or "Action:Set boolean value" to assign this key to be a primary key. i.e. unique key.
Then calls "Action:Save" to save this item which has primary key(s). Plugin first fetches the objectId which has these unique key(s), then overwrites it with prepared item.
"Condition:On save" or "Condition:On save error" will be triggered after saved, too.
Primary keys also could be defined at "Primary keys" in properties table, or by "Action:Set primary keys". Multiple keys are joined by ",". For example, joining primary keys "key0", and "key1" to "key0,key1".
Set parameter "Key type" to "primary key" in "Action:Set value", or "Action:Set boolean value" to assign this key to be a primary key. i.e. unique key.
Then calls "Action:Save" to save this item which has primary key(s). Plugin first fetches the objectId which has these unique key(s), then overwrites it with prepared item.
"Condition:On save" or "Condition:On save error" will be triggered after saved, too.
Primary keys also could be defined at "Primary keys" in properties table, or by "Action:Set primary keys". Multiple keys are joined by ",". For example, joining primary keys "key0", and "key1" to "key0,key1".
Save all
Sample capx
This plugin also support save multiple items.
Sample capx
This plugin also support save multiple items.
- Call :Action:Add to queue" to append prepared items into save-all queue.
- Finally call "Action:Save all" to save all items in save-all queue.
Read items
There are some ways to read items back,
There are some ways to read items back,
- using filter to get matched items, or
- using itemID (objectId) to get a specific item.
Read by filter
Sample capx
Follows these steps to build a new filter
1. Call "Action:1. New" to create a new filter.
2. Call one of these actions to add filter condition,
Sample capx
Follows these steps to build a new filter
1. Call "Action:1. New" to create a new filter.
2. Call one of these actions to add filter condition,
- Action:2. all values
- Action:2. value compare,included "equal to", "not equal to", "greater than", "less than", "greater than or equal to", "less than or equal to"
- Action:2. boolean value compare
- Action:2. timestamp constraint
- Action:2. string pattern compare
- Action:2. key exist
- Action:2. itemID include
- Action:2. value include
Number value comparison
AND, OR
String value comparison
Date comparison
Null comparison
3. set order of items by "Action:3. order"
4. set fetched fields by "Action:4. add a key", or "Action:4. Get linked object".
4. set fetched fields by "Action:4. add a key", or "Action:4. Get linked object".
Read items
After build a new filter by these steps, call one of request actions to start fetching -
After build a new filter by these steps, call one of request actions to start fetching -
Pages
- Action:Turn to page
- Action:Update current page
- Action:Turn to next page
- Action:Turn to previous page
Start from any index
Or call "Action:Load in a range" to fetch ordered items started from any index.
Do not mix this action with pages type requests described at previous section.
Or call "Action:Load in a range" to fetch ordered items started from any index.
Do not mix this action with pages type requests described at previous section.
All items
Get all queried items by "Action:Load all queried items".
This action will fetch queried items page by page (each page is 1000 lines), until lines count of received page is less than 1000. i.e. the last page.
Get all queried items by "Action:Load all queried items".
This action will fetch queried items page by page (each page is 1000 lines), until lines count of received page is less than 1000. i.e. the last page.
Random items
Sample capx
Get queried items by "Action:Get random queried items".
This action first fetches all queried itemID (objectId) back, then pick some itemID randomly. Finally fetching items by these picked itemID. It needs at last 2 requests to get random items.
Or user could get all queried items by "Action:Load all queried items", then get items randomly while received.
Sample capx
Get queried items by "Action:Get random queried items".
This action first fetches all queried itemID (objectId) back, then pick some itemID randomly. Finally fetching items by these picked itemID. It needs at last 2 requests to get random items.
Or user could get all queried items by "Action:Load all queried items", then get items randomly while received.
Retrieve items
"Condition:On received" will be triggered when received requested messages. Then uses these methods to retrieve values.
"Condition:On received" will be triggered when received requested messages. Then uses these methods to retrieve values.
Retrieve items in for each loop
"Condition:For each item" or "Condition:For each item in a range" could retrieve items in a for each loop, gets item's value by these expressions.
"Condition:For each item" or "Condition:For each item in a range" could retrieve items in a for each loop, gets item's value by these expressions.
- Expression:CurItemIndex, which is 0-based
- Expression:CurItemID
- Expression:CurSentAt
- Expression:CurItemContent
- "Expression:CurItemContent" without any parameter, will return key-value pairs of current item in JSON string.
- "Expression:CurItemContent( key )" , will return the value of a specific key, or return 0 if the key does not exist.
- "Expression:CurItemContent( key, default_value )" , will return the value of a specific key, or return default value if the key does not exist.
Retrieve items by item index
Get received item by item index by "Expression:Index2ItemContent". Like "Expression:CurItemContent", there are 3 kinds of
return value.
Get received item by item index by "Expression:Index2ItemContent". Like "Expression:CurItemContent", there are 3 kinds of
return value.
- "Expression:Index2ItemContent( index )", will return key-value pairs of indexed item in JSON string.
- "Expression:Index2ItemContent( index, key )" , will return the value of a specific key, or return 0 if the key does not exist.
- "Expression:Index2ItemContent( index, key, default_value )" , will return the value of a specific key, or return default value if the key does not exist.
Retrieve all items in JSON string
Get JSON string of all received items by "Expression:ItemsToJSON".
Get JSON string of all received items by "Expression:ItemsToJSON".
Read value by primary key
Sample capx
Since an item could be retrieved by index(primary) keys in loaded items. Value of a specific field in this item could be read by "Expression:At". There are 2 formats in this expression.
Sample capx
Since an item could be retrieved by index(primary) keys in loaded items. Value of a specific field in this item could be read by "Expression:At". There are 2 formats in this expression.
- "Expression:At( valueOfIndexKey0, valueOfIndexKey1, valueOfIndexKey2, .... , dataKey )", it first gets item 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 get the value of dataKey. Returns defaultValue if the target value is not found.
Read by object ID of item
Sample capx
Call "Action:Load by itemID" to read item by object ID."Condition:On load by itemID" will be triggered when loading success, otherwise "Condition:On load by itemID error" will be triggered. Get item fields by these expressions-
Sample capx
Call "Action:Load by itemID" to read item by object ID."Condition:On load by itemID" will be triggered when loading success, otherwise "Condition:On load by itemID error" will be triggered. Get item fields by these expressions-
- Expression:LastFetchedItemID
- Expression:LastFetchedSavedTime
- Expression:LastFetchedItemContent
- "Expression:LastFetchedItemContent" without any parameter,will return key-value pairs of fetched item in JSON string.
- "Expression:LastFetchedItemContent( key ) , will return the value of a specific key, or return 0 if the key does not exist.
- "Expression:LastFetchedItemContent( key, default_value ) , will return the value of a specific key, or return default value if the key does not exist.
"Action:Load by itemID" will get item by itemID directly without querying, therefor it can not assign fetched fields.
Remove items
There are two ways to remove items -
There are two ways to remove items -
- by itemID (objectId),
- by filter.
Remove by itemID
Sample capx
Call "Action:Remove by itemID" to remove an item by object ID.
"Condition:On remove by itemID" will be triggered when removing success. Get removed itemID by "Expression:LastRemovedItemID". Otherwise "Condition:On remove by itemID error" will be triggered.
Sample capx
Call "Action:Remove by itemID" to remove an item by object ID.
"Condition:On remove by itemID" will be triggered when removing success. Get removed itemID by "Expression:LastRemovedItemID". Otherwise "Condition:On remove by itemID error" will be triggered.
Remove by filter
Sample capx
It also supports removing items picked by filter.
First creating a new filter described at previous section, then call "Action:Remove queried items" to remove them.
"Condition:On remove queried items" will be triggered when all items removed success, otherwise "Condition:On remove queried items error" will be triggered.
Sample capx
It also supports removing items picked by filter.
First creating a new filter described at previous section, then call "Action:Remove queried items" to remove them.
"Condition:On remove queried items" will be triggered when all items removed success, otherwise "Condition:On remove queried items error" will be triggered.
Items count
Get filtered items count by "Action:Get items count" after build a new filter. The result is put at "Expression:LastItemsCount" under "Condition:On get items count", otherwise "Condition:On get items count error" if requesting failed.
Get filtered items count by "Action:Get items count" after build a new filter. The result is put at "Expression:LastItemsCount" under "Condition:On get items count", otherwise "Condition:On get items count error" if requesting failed.
Related objects
Items in other tables could be linked into current item of a key.
Items in other tables could be linked into current item of a key.
Save linked object
There are two kinds of linking actions -
There are two kinds of linking actions -
- "Action:Link to current user" ( sample capx )
- "Action:Link to object" ( sample capx )
Read linked object
Linked object would not be fetched automatically, Call "Action:4. Get linked object" to force this request to read this linked object back.
After read completed under "Condition:On received" or "Condition:On load by itemID", get the value of linked object by "Expression:CurItemContent", or "Expression:Index2ItemContent". "Expression:LastFetchedItemContent" by a specific key. For example.
Linked object would not be fetched automatically, Call "Action:4. Get linked object" to force this request to read this linked object back.
After read completed under "Condition:On received" or "Condition:On load by itemID", get the value of linked object by "Expression:CurItemContent", or "Expression:Index2ItemContent". "Expression:LastFetchedItemContent" by a specific key. For example.
- Expression:CurItemContent( "ownerData.name" )
- Expression:CurItemContent( "ownerData.name", default_value )
- Expression:Index2ItemContent( index, "ownerData.name" )
- Expression:Index2ItemContent( index, "ownerData.name", default_value )
- Expression:LastFetchedItemContent( "ownerData.name" )
- Expression:LastFetchedItemContent( "ownerData.name", default_value )
Instance of request
Designer could create a new instance for each request. Or place multiple rex_backendless_itemtable object for each different kind of request.
Designer could create a new instance for each request. Or place multiple rex_backendless_itemtable object for each different kind of request.
Sort or filter data at local
Sample capx
Items read from parse could be put into rex_taffydb object by "Action:Insert JSON data" (rex_taffydb) with "Expression:ItemsToJSON" ((rex_parse_itemtable). Then user could sort or filter these items at local by this rex_taffydb object.
Sample capx
Items read from parse could be put into rex_taffydb object by "Action:Insert JSON data" (rex_taffydb) with "Expression:ItemsToJSON" ((rex_parse_itemtable). Then user could sort or filter these items at local by this rex_taffydb object.