In order to create a record and save the data to our table, we will use the next format and set our attributes with the
set
command.
Here is another example doing the same action. Here we will set our attributes under the save
command.
car_code: 12468,
car_model: "Test car",
car_year: 2014,
car_color: "red",
available: true,stock: 5,
success: function(car) {// Object saved successfully.alert('New object created with objectId: ' + car.id);},error: function(car, error) {// Object saving failed.// error is a Simbla.Error with an error code and message.alert('Failed to create new object, with error code: ' + error.message);}
After publishing and running the code, you can go to your table in your database and see how a new record has been added with the data you entered. Please make sure you hit the refresh button above your table.
Here is how our table looks after running the code:
As you can see, there are three automatic fields provided by the the system for your convenience and for future use:
1. objectId - a unique string identifying each saved record.
2. createdAt - the exact time and date the record was created.
3. updatedAt - the exact time and date of the last modification made.