Adding permanent data storage to your apps is the last step to making them real-world. The apps you use everyday are driven by data "in the cloud".
First time using App Lab table data storage? Read a short overview of what it is and how to use it here.
The record parameter must be a javascript object variable or a javascript object defined using curly brace and colon notation (see examples below). The object cannot have an "id" property. The record created in the table is then returned as a parameter to the callback function. Data is only accessible to the app that created the table. To View your app's table data, click 'View data' in App Lab and click the table name you want to view.
Collect favorite food data from friends and store it in a table.
// Collect favorite food data from friends and store it in a table. textInput("nameInput", "What is your name?"); textInput("ageInput", "What is your age?"); textInput("foodInput", "What is your favorite food?"); button("doneButton", "Done"); onEvent("doneButton", "click", function() { var favFoodData={}; favFoodData.name = getText("nameInput"); favFoodData.age = getNumber("ageInput"); favFoodData.food = getText("foodInput"); createRecordSync("fav_foods", favFoodData); });
createRecordSync(table, record)
Name | Type | Required? | Description |
---|---|---|---|
table | String | The name of the table the record should be added to. A new table gets created if it doesn't exist. | |
record | Object | The data to be stored in the record. Either a javascript object variable or a javascript object defined using curly brace and colon notation (see examples above). |
Found a bug in the documentation? Let us know at documentation@code.org