I want to update only specified columns, when I execute update(table).replace(model)
it replaces all data corresponding to primary key. How to update only specified column without writing custom queries.
You have to declare your function with Insertable
like that:
Future updateVisit(Insertable<Visit> visit) => update(visits).replace(visit);
so, when you call a function you can do this:
visitDao.updateVisit(visit.copyWith(completed: newValue))
or
visitDao.updateVisit(VisitsCompanion(id: Value(visitId), checkOut: Value(DateTime.now())));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With