insert method
Implementation
Future<void> insert(final Model model, {int? selectAllLength}) async {
if (kIsWeb) {
selectAllLength ??= (await selectAll()).length;
final Map<String, dynamic> map = await toMap(model);
bool inserted = false;
if (sqfliteTable.primaryKeyColumnList.isNotEmpty) {
inserted = await _insertOnConstraint(map,
constraintColumnList: sqfliteTable.primaryKeyColumnList,
selectAllLength: selectAllLength);
}
if (!inserted && sqfliteTable.uniqueColumnList.isNotEmpty) {
inserted = await _insertOnConstraint(map,
constraintColumnList: sqfliteTable.uniqueColumnList,
selectAllLength: selectAllLength);
}
if (!inserted) {
for (final c.Sqflite column in sqfliteTable.columnList) {
await Preference('${sqfliteTable.name}${column.name}$selectAllLength')
.setValue(map[column.name]);
}
}
} else {
await (await sqflite).insert('`${sqfliteTable.name}`', await toMap(model),
conflictAlgorithm: ConflictAlgorithm.replace);
}
}