mirror of
https://github.com/moparisthebest/PhoneGap-SQLitePlugin-Android
synced 2024-11-25 18:12:16 -05:00
markdown
This commit is contained in:
parent
4d795d8425
commit
0f546fd088
90
README.md
90
README.md
@ -12,40 +12,40 @@ replacement.
|
|||||||
|
|
||||||
DISCLAIMER:
|
DISCLAIMER:
|
||||||
|
|
||||||
I'm brand new to objective-c, so there could be problems with my code!
|
I'm brand new to objective-c, so there could be problems with my code!
|
||||||
Please tell me. joenoon@gmail.com
|
Please tell me. joenoon@gmail.com
|
||||||
|
|
||||||
Added:
|
Added:
|
||||||
|
|
||||||
obj-c:
|
- obj-c:
|
||||||
batch execution support
|
- batch execution support
|
||||||
query parameter binding
|
- query parameter binding
|
||||||
perform after delay so js-objc call doesn't need to wait for response
|
- perform after delay so js-objc call doesn't need to wait for response
|
||||||
callbacks moved out of instance and into options of each method call
|
- callbacks moved out of instance and into options of each method call
|
||||||
path just takes filename, and path is put in Documents folder
|
- path just takes filename, and path is put in Documents folder
|
||||||
added rowsAffected, insertId
|
- added rowsAffected, insertId
|
||||||
success callback response is { insertId: x, rowsAffected: y, rows: z }
|
- success callback response is { insertId: x, rowsAffected: y, rows: z }
|
||||||
error callback response is { message: x }
|
- error callback response is { message: x }
|
||||||
|
|
||||||
js (coffeescript):
|
- js (coffeescript):
|
||||||
new implementation
|
- new implementation
|
||||||
first cut transaction support
|
- first cut transaction support
|
||||||
callbacks per-statement, even within transaction
|
- callbacks per-statement, even within transaction
|
||||||
somewhat similar api to the webkit/phonegap default
|
- somewhat similar api to the webkit/phonegap default
|
||||||
|
|
||||||
Removed:
|
Removed:
|
||||||
|
|
||||||
quota limit webkit html5 db patching
|
- quota limit webkit html5 db patching
|
||||||
exit from app
|
- exit from app
|
||||||
(I don't think either of these would make it through the approval process)
|
- (I don't think either of these would make it through the approval process)
|
||||||
|
|
||||||
Other notes:
|
Other notes:
|
||||||
|
|
||||||
I played with the idea of batching responses into larger sets of
|
I played with the idea of batching responses into larger sets of
|
||||||
writeJavascript on a timer, however there was only a barely noticeable
|
writeJavascript on a timer, however there was only a barely noticeable
|
||||||
performance gain. So I took it out, not worth it. However there is a
|
performance gain. So I took it out, not worth it. However there is a
|
||||||
massive performance gain by batching on the client-side to minimize
|
massive performance gain by batching on the client-side to minimize
|
||||||
PhoneGap.exec calls using the transaction support.
|
PhoneGap.exec calls using the transaction support.
|
||||||
|
|
||||||
Installing
|
Installing
|
||||||
==========
|
==========
|
||||||
@ -60,41 +60,41 @@ Use the resulting javascript file in your HTML.
|
|||||||
|
|
||||||
Look for the following to your project's PhoneGap.plist:
|
Look for the following to your project's PhoneGap.plist:
|
||||||
|
|
||||||
<key>Plugins</key>
|
<key>Plugins</key>
|
||||||
<dict>
|
<dict>
|
||||||
...
|
...
|
||||||
</dict>
|
</dict>
|
||||||
|
|
||||||
Insert this in there:
|
Insert this in there:
|
||||||
|
|
||||||
<key>PGSQLitePlugin</key>
|
<key>PGSQLitePlugin</key>
|
||||||
<string>PGSQLitePlugin</string>
|
<string>PGSQLitePlugin</string>
|
||||||
|
|
||||||
General Usage
|
General Usage
|
||||||
=============
|
=============
|
||||||
|
|
||||||
(You're using Coffeescript right? Of course you are.)
|
(You're using Coffeescript right? Of course you are.)
|
||||||
|
|
||||||
db = new PGSQLitePlugin("test_native.sqlite3")
|
db = new PGSQLitePlugin("test_native.sqlite3")
|
||||||
db.executeSql('DROP TABLE IF EXISTS test_table')
|
db.executeSql('DROP TABLE IF EXISTS test_table')
|
||||||
db.executeSql('CREATE TABLE IF NOT EXISTS test_table (id integer primary key, data text, data_num integer)')
|
db.executeSql('CREATE TABLE IF NOT EXISTS test_table (id integer primary key, data text, data_num integer)')
|
||||||
|
|
||||||
db.transaction (tx) ->
|
db.transaction (tx) ->
|
||||||
|
|
||||||
tx.executeSql [ "INSERT INTO test_table (data, data_num) VALUES (?,?)", "test", 100], (res) ->
|
tx.executeSql [ "INSERT INTO test_table (data, data_num) VALUES (?,?)", "test", 100], (res) ->
|
||||||
|
|
||||||
# success callback
|
# success callback
|
||||||
|
|
||||||
console.log "insertId: #{res.insertId} -- probably 1"
|
console.log "insertId: #{res.insertId} -- probably 1"
|
||||||
console.log "rowsAffected: #{res.rowsAffected} -- should be 1"
|
console.log "rowsAffected: #{res.rowsAffected} -- should be 1"
|
||||||
|
|
||||||
# check the count (not a part of the transaction)
|
# check the count (not a part of the transaction)
|
||||||
db.executeSql "select count(id) as cnt from test_table;", (res) ->
|
db.executeSql "select count(id) as cnt from test_table;", (res) ->
|
||||||
console.log "rows.length: #{res.rows.length} -- should be 1"
|
console.log "rows.length: #{res.rows.length} -- should be 1"
|
||||||
console.log "rows[0].cnt: #{res.rows[0].cnt} -- should be 1"
|
console.log "rows[0].cnt: #{res.rows[0].cnt} -- should be 1"
|
||||||
|
|
||||||
, (e) ->
|
, (e) ->
|
||||||
|
|
||||||
# error callback
|
# error callback
|
||||||
|
|
||||||
console.log "ERROR: #{e.message}"
|
console.log "ERROR: #{e.message}"
|
||||||
|
Loading…
Reference in New Issue
Block a user