Skip to content

Instantly share code, notes, and snippets.

@ericgrandt
Last active January 16, 2019 21:10
Show Gist options
  • Save ericgrandt/8f27c215287a7b526d82d78c90dc77f7 to your computer and use it in GitHub Desktop.
Save ericgrandt/8f27c215287a7b526d82d78c90dc77f7 to your computer and use it in GitHub Desktop.
newUser(User user) async {
final db = await database;
var res = await db.insert('user', user.toJson());
return res;
}
getUser(int id) async {
final db = await database;
var res = await db.query('user', where: 'id = ?', whereArgs: [id]);
return res.isNotEmpty ? User.fromJson(res.first) : Null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment