You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Jayr Alencar edited this page Mar 30, 2016
·
3 revisions
1 - Just entity and data (Synchronous )
The object keys must have the same names as the columns in the database table.
varid=sqlite.insert('COMPANYS',{NAME: "My Company"});console.log(id)//Last insert id
2 - Just entity and data (Asynchronous )
sqlite.insert('COMPANYS',{NAME: "My Company"},function(id){console.log(id)//last insert id});
3 - Synchronous - Common Sql
varsqlite=require('sqlite-sync');sqlite.connect('myDatabase.db');//returns the last idvarlast_insert_id=sqlite.run("INSERT INTO myTable (name) VALUES ('Jayr')");//Prepared SQLvarlast_insert_id=sqlite.run("INSERT INTO myTable (name) VALUES (?)",['Jayr']);
4 - Asynchronous - Common Sql
sqlite.connect('myDatabase.db');sqlite.run("INSERT INTO myTable (name) VALUES ('Jayr')",function(id){//returns the last idconsole.log(id);});//Prepared SQLsqlite.run("INSERT INTO myTable (name) VALUES (?)",['Jayr'],function(id){//returns the last idconsole.log(id)});