upsert method
- IpAddress ip,
- IpGeoLocation geo, {
- String? language,
Creates or updates the provided geo
in the database.
Implementation
Future<void> upsert(
IpAddress ip,
IpGeoLocation geo, {
String? language,
}) async {
data[(ip, language)] = DtoIpGeoLocation(geo, PreciseDateTime.now());
await safe<DtoIpGeoLocation?>((db) async {
final result = await db
.into(db.geoLocations)
.insertReturning(
geo.toDb(ip, language: language),
onConflict: DoUpdate((_) => geo.toDb(ip, language: language)),
);
return _IpGeoLocationDb.fromDb(result);
});
}