createIfNotExists method
Create a new row only if the value is not existed.
var userEloquent = UserEloquent();
userEloquent.createIfNotExists(check:{'name':'john'},create:{'password':'pass'});
Implementation
// create user which name is john and password is pass only if name 'john' is not existed.
/// userEloquent.createIfNotExists(check:{'name':'john'},create:{'password':'pass'});
///
/// ```
@override
Future<int?> createIfNotExists(
{required Map<String, Object?> check,
required Map<String, Object?> create}) async {
final db = await getDatabase;
List result = await _where(check);
if (result.isNotEmpty) {
return null;
}
create.addAll(check);
resetAll();
return await db.insert(tableName, create);
}