CloudDB Component
Properties
projectID Gets the ProjectID for this CloudDB project.
Data type: string |
||
Designer Writable | true |
<clouddb name="clouddbName" projectID="yailcode1"> |
Code Writeable | true |
clouddbName.projectID = "yailcode1" |
Code Readable | true |
let variable = clouddbName.projectID |
redisPort The Redis Server port to use. Defaults to 6381
Data type: number |
||
Designer Writable | true |
<clouddb name="clouddbName" redisPort="6381"> |
Code Writeable | true |
clouddbName.redisPort = 6381 |
Code Readable | true |
let variable = clouddbName.redisPort |
redisServer The Redis Server to use to store data. A setting of "clouddb.appinventor.mit.edu" means that the MIT server will be used.
Data type: string |
||
Designer Writable | true |
<clouddb name="clouddbName" redisServer="clouddb.appinventor.mit.edu"> |
Code Writeable | true |
clouddbName.redisServer = "clouddb.appinventor.mit.edu" |
Code Readable | true |
let variable = clouddbName.redisServer |
token This field contains the authentication token used to login to the backed Redis server. For the "DEFAULT" server, do not edit this value, the system will fill it in for you. A system administrator may also provide a special value to you which can be used to share data between multiple projects from multiple people. If using your own Redis server, set a password in the server's config and enter it here.
Data type: string |
||
Designer Writable | true |
<clouddb name="clouddbName" token="token"> |
Code Writeable | false | |
Code Readable | false |
useSSL Set to true to use SSL to talk to CloudDB/Redis server. This should be set to True for the "DEFAULT" server.
Data type: boolean |
||
Designer Writable | true |
<clouddb name="clouddbName" useSSL="true"> |
Code Writeable | false | |
Code Readable | false |
class The styling class of the the component
Data type: string |
||
Designer Writable | true |
<clouddb name="clouddbName" class="Test class"> |
Code Writeable | false | |
Code Readable | false |
id The styling id of the the component
Data type: string |
||
Designer Writable | true |
<clouddb name="clouddbName" id="Test id"> |
Code Writeable | false | |
Code Readable | false |
name The name of the component that will be used to refer to it in code.
Data type: string |
||
Designer Writable | true |
<clouddb name="clouddbName" name="testComponent"> |
Code Writeable | false | |
Code Readable | false |
Methods
Method name | Description | Parameters | ||||
---|---|---|---|---|---|---|
appendValueToList |
Append a value to the end of a list atomically. If two devices use this function simultaneously, both will be appended and no data lost. clouddbName.appendValueToList(tag, itemToAdd) clouddbName.appendValueToList("Test tag", "any") |
|
||||
clearTag |
Remove the tag from CloudDB. clouddbName.clearTag(tag) clouddbName.clearTag("Test tag") |
|
||||
cloudConnected |
Returns true if we are on the network and will likely be able to connect to the CloudDB server. clouddbName.cloudConnected() |
|
||||
getTagList |
Asks CloudDB to retrieve all the tags belonging to this project. The resulting list is returned in the event TagList. clouddbName.getTagList() |
|
||||
getValue |
GetValue asks CloudDB to get the value stored under the given tag. It will pass the result to the GotValue will be given. clouddbName.getValue(tag, valueIfTagNotThere) clouddbName.getValue("Test tag", "any") |
|
||||
removeFirstFromList |
Obtain the first element of a list and atomically remove it. If two devices use this function simultaneously, one will get the first element and the the other will get the second element, or an error if there is no available element. When the element is available, the FirstRemoved event will be triggered. clouddbName.removeFirstFromList(tag) clouddbName.removeFirstFromList("Test tag") |
|
||||
storeValue |
Asks CloudDB to store the given value under the given tag. clouddbName.storeValue(tag, valueToStore) clouddbName.storeValue("Test tag", "any") |
|
||||
addEventListener |
Method used to create event listeners. See Events below for samples. |
|
Events
Event name | Description | Parameters | ||||
---|---|---|---|---|---|---|
cloudDBError | Indicates that an error occurred while communicating with the CloudDB Redis server.clouddbName.addEventListener( "cloudDBError", function (message) { //Your code here } ) |
|
||||
dataChanged | Indicates that the data in the CloudDB project has changed. Launches an event with the tag that has been updated and the value it now has.clouddbName.addEventListener( "dataChanged", function (tag, value) { //Your code here } ) |
|
||||
firstRemoved | Event triggered by the RemoveFirstFromList function. The argument value is the object that was the first in the list, and which is now removed.clouddbName.addEventListener( "firstRemoved", function (value) { //Your code here } ) |
|
||||
gotValue | Indicates that a GetValue request has succeeded.clouddbName.addEventListener( "gotValue", function (tag, value) { //Your code here } ) |
|
||||
tagList | Event triggered when we have received the list of known tags. Run in response to a call to the GetTagList function.clouddbName.addEventListener( "tagList", function (value) { //Your code here } ) |
|
||||
updateDone | Indicates that operations that store data to CloudDB have completed.clouddbName.addEventListener( "updateDone", function (tag, operation) { //Your code here } ) |
|