This document summarizes a presentation by Pratik Patel on working with data in Titanium. The presentation covers strategies for using SQL and NoSQL databases like SQLite and MongoDB. It also discusses functional programming concepts like map, flatten, and sortBy using Underscore.js. The presentation concludes with a discussion of synchronization, performance, and architectural considerations for mobile apps.
9. map
• map is the name of a higher-order function
that applies a given function to each element
of a list, returning a list of results
• like doing a transformation
PRATIK PATEL | CTO
16. sqlite
var
db
=
Titanium.Database.open('mydb');
!
db.execute('CREATE
TABLE
IF
NOT
EXISTS
DATABASETEST
(ID
INTEGER,
NAME
TEXT)');
db.execute('DELETE
FROM
DATABASETEST');
!
db.execute('INSERT
INTO
DATABASETEST
(ID,
NAME
)
VALUES(?,?)',1,'Name
1');
db.execute('UPDATE
DATABASETEST
SET
NAME
=
?
WHERE
ID
=
?',
updateName,
updateId);
var
rows
=
db.execute('SELECT
*
FROM
DATABASETEST');
!
while
(rows.isValidRow())
{
Titanium.API.info('ID:
'
+
rows.field(0)
+
'
NAME:
'
+
rows.fieldByName('name')
+
'
COLUMN
NAME
'
+
rows.fieldName(0));
rows.next();
}
PRATIK PATEL | CTO
24. PLAIN JSON + REST
• Standard REST endpoints
• You manage the sync yourself
PRATIK PATEL | CTO
25. SQLite
• You manage the sync yourself
• Manual conversion to/from SQL
• ORM’s for Titanium
• BUT: why not send the actual SQLite file
over the wire???
PRATIK PATEL | CTO