insert method

  1. @override
Future<int> insert(
  1. String table,
  2. JSON values, {
  3. String? nullColumnHack,
  4. ConflictAlgorithm? conflictAlgorithm,
})
override

This method helps insert a map of values into the specified table and returns the id of the last inserted row.

   var value = {
     'age': 18,
     'name': 'value'
   };
   int id = await db.insert(
     'table',
     value,
     conflictAlgorithm: ConflictAlgorithm.replace,
   );

0 could be returned for some specific conflict algorithms if not inserted.

Implementation

@override
Future<int> insert(
  String table,
  JSON values, {
  String? nullColumnHack,
  sqlite_api.ConflictAlgorithm? conflictAlgorithm,
}) async {
  final id = await _delegate.insert(
    table,
    values,
    nullColumnHack: nullColumnHack,
    conflictAlgorithm: conflictAlgorithm,
  );
  if (id != -1) {
    sendTableTrigger({table});
  }
  return id;
}