insertOrUpdate method

  1. @override
Future<TEntity?> insertOrUpdate(
  1. TEntity item, {
  2. bool? useIsolate,
})
inherited

Implementation

@override
Future<TEntity?> insertOrUpdate(
  TEntity item, {
  final bool? useIsolate,
}) async {
  final db = await dbContext.database;
  final spawnIsolate = useIsolate ?? useIsolateDefault;

  final response = !spawnIsolate
      ? wInsertOrUpdate(item)
      : await compute(wInsertOrUpdate, item);
  final updated = await db.insert(
      response.entity.meta.tableName, response.map,
      conflictAlgorithm: ConflictAlgorithm.replace);
  return updated > 0 ? response.entity as TEntity? : null;
}