Skip to content

Instantly share code, notes, and snippets.

@Rahiche
Created December 11, 2018 13:56
Show Gist options
  • Save Rahiche/e6611787dbb9d3aa80a48152c6155d9c to your computer and use it in GitHub Desktop.
Save Rahiche/e6611787dbb9d3aa80a48152c6155d9c to your computer and use it in GitHub Desktop.
newClient(Client newClient) async {
final db = await database;
//get the biggest id in the table
var table = await db.rawQuery("SELECT MAX(id)+1 as id FROM Client");
int id = table.first["id"];
//insert to the table using the new id
var raw = await db.rawInsert(
"INSERT Into Client (id,first_name,last_name,blocked)"
" VALUES (?,?,?,?)",
[id, newClient.firstName, newClient.lastName, newClient.blocked]);
return raw;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment