כאן תוכלו למצוא את כל התשובות לכל השאלות הנוגעות
למערכת MyBusiness CRM.
לשאלות בנושאים נוספים אשר לא מופיעים במדריך ניתן
לפנות ישירות במייל ובטלפון, למידע נוסף לחץ כאן.
Data is stored and built around the Simbla.object that contains key-value pairs of JSON-compatible data.
This data is schemaless, so just set any key-value pairs you want and we will store it.
Keys have to be strings. Values can be strings, numbers, Booleans or arrays.
In our example, we will track the stock of cars in a showroom using our "Cars" table as given in the javascript page.
Before you get started, create a table with a few columns and manually add a raw to test that the table is working as you want it to.
Make sure all of your permissions of the table are set to public before you start.
A Simbla.object could contain:
car_model: “Ferarri” , available: true , stock: 2
Before you start building your web application, you will need to create a subclass and use the Simbla.Object.extended method.
Any Simbla.query will react with any Simbla.object with the same classname:
// Syntax to create a new subclass of Simbla.object.
var Cars = Simbla.Object.extend("Cars");
// Create a new instance of the class
var car = new Cars();
var car = new Simbla.Object("Cars");
var query = new Simbla.Query(car);
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.
Retrieving An Object
After saving the object we would like to call it back and present it on our page. To do so we will use the objectId of the record which is in our example "uD3KzzDd2b". Keep in mind that all objectId are unique values, so if you are following the steps please copy your objectId from your table.
In order to retrieve our object we are going to use the Simbla.query that we will explain more about in our next guide.
We wish to present our final result on our page using our HTML element. Here is our HTML code:
<div Style="padding:30px;border:1px solid red">
<H1 Id="cmodel"></H1></br>
<h3 id="cyear"></h3></br></br>
<p id="ccode"></p></br></br>
</div>
Our Javascript code retrieving the record:
var car = Simbla.Object.extend("Cars");
var query = new Simbla.Query(car);
query.get("qxFYhsu14o", {
success: function(car) {
$("#cmodel").html(car.get("car_model"));
$("#cyear").html(car.get("car_year"));
$("#ccode").html(car.get("car_code"));
},
error: function(car, error) {
alert("Error - The object was not retrieved successfully" + error.message);
}
});
The three reserved values are provided as properties and cannot be retrieved using the 'get' method nor modified with the 'set' method:
var objectId = car.id;
var updatedAt = car.updatedAt;
var createdAt = car.createdAt;
Updating Objects
Updating an object is actually saving over the old object, in the next example we are going to use our "WY0DQyj9L6 " record, remember that each record is unique so please check your record before testing it out.
We are basically getting the "WY0DQyj9L6" record, setting new info and saving it:
var car = Simbla.Object.extend("Cars");
var query = new Simbla.Query(car);
query.get("WY0DQyj9L6", {
success: function(car) {
car.set("car_year", 2016);
car.set("car_model", "new car");
car.save(null, {
success: function(car) {
alert("Update succeeded") ;
},
error: function(car, error) {
alert("Error - update failed" + error.message);
}
});
},
error: function(car, error) {
alert("Error - The object was not retrieved successfully" + error.message);
}
});
Deleting Objects
To delete an object we will use the object.destroy method:
var car = Simbla.Object.extend("Cars");
var query = new Simbla.Query(car);
query.get("WY0DQyj9L6 ", {
success: function(car) {
car.destroy({
success: function(car) {
alert("Object deleted");
},
error: function(car, error) {
alert("Object not deleted");
}
});
},
error: function(car, error) {
alert("Object not found");
}
});
Yad Harutsim St 12, Tel-Aviv
Israel 6770005
972.77-6049599+
support@mybusiness-crm.com
© כל הזכויות שמורות ל- 2019 MyBusiness -CRM