Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

flutter moor - update only specified columns without custom query

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.

like image 296
Ashique bzq Avatar asked Dec 25 '19 07:12

Ashique bzq


Video Answer


1 Answers

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())));
like image 139
Rafael Menicucci Avatar answered Nov 15 '22 06:11

Rafael Menicucci