how to use where on doUpdate when using insertAll? #3303
Unanswered
rizalahmaddd
asked this question in
Q&A
Replies: 1 comment
-
You can use await batch((batch) {
for (final entry in data) {
batch.insert(
flags,
entry,
onConflict: DoUpdate.withExcluded(
(Flag old) => entry,
where: (Flags old, Flags excluded) => old.updatedAt.isSmallerOrEqual(excluded.updatedAt)),
);
}
}); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
If a conflict occurs, I want to compare the updatedAt column. How can I do that? I cannot access the new data in the DoUpdate callback.
await batch((batch) { batch.insertAll( flags, data, onConflict: DoUpdate( (Flag old) => newData? where: (Flags old) => old.updatedAt.isSmallerOrEqual(newData.updatedAt?), ), ); });
thanks.
Beta Was this translation helpful? Give feedback.
All reactions