getLastInsertId static method

Future getLastInsertId(
  1. String tableName,
  2. String primaryKey
)

Get the last inserted ID (DB-specific).

Implementation

static Future<dynamic> getLastInsertId(
    String tableName, String primaryKey) async {
  await _ensureConnected();

  if (_driver == DBDriver.postgres) {
    final result = await query("SELECT lastval() as id");
    return _convertDatabaseId(result.first['id']);
  } else {
    final result = await query("SELECT LAST_INSERT_ID() as id");
    return _convertDatabaseId(result.first['id']);
  }
}