I use SQL proxy in my Sencha Touch 2 application, and I can store and retrieve data offline.
What I cannot do and what the Sencha documentation seems to provide is not how to configure the Sencha SQL repository.
For example, to create SQL-based storage, I did the following -
Ext.define("MyApp.model.Customer", {
extend: "Ext.data.Model",
config: {
fields: [
{name: 'id', type: 'int'},
{name: 'name', type: 'string'},
{name: 'age', type: 'string'}
],
proxy: {
type: "sql",
database: "MyDb",
}
}
});
1. Now, how can I specify the size of the database?
2. How to specify restrictions on fields such as a unique, primary key, etc.
Let's say I have 4 columns in my database: pid, name, age, phone
I want to have a primary key for several fields: (pid, name)
If I were creating a table through an SQL query, I would do something like -
CREATE TABLE Persons
(
pid int,
name varchar(255),
age int,
phone int,
primary key (pid,name)
);
Now, how do I achieve the same model?
3. SQL-, :
var query = "SELECT * from CUSTOMER";
var db = openDatabase('MyDb', '1.0', 'MyDb', 2 * 1024 * 1024);
db.transaction(function (tx) {
tx.executeSql(query, [], function (tx, results) {
// do something here
}, null);
});
?