tekartik / sembast.dart

Simple io database
BSD 2-Clause "Simplified" License
780 stars 64 forks source link

Overwrite the record with same int id #316

Closed deep1931 closed 1 year ago

deep1931 commented 2 years ago

Hello,

I have seen, when we insert record on same id which is already used as key, then it return null. Is there any way to overwrite that id, no matter record already there or not. If new record, then insert it, otherwise replace it.

Please help.

Regards.

alextekartik commented 2 years ago

If I understand correctly, indeed insert will fail if the record exists. update wil fail if the record does not exist. It seems the solution you are looking for is put which will create the record if it does not exist.

deep1931 commented 2 years ago

@alextekartik Thanks for update.

Another issue which came some time, which stoped insertion process.

Before error-

-----> List Messages Keys Len 5 -----> List Messages Len 5

length or keys array and messages array is same but it is throwing some error related to range, which i am unable to trace.

ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: RangeError (index): Invalid value: Not in inclusive range 0..4: 5

Regards

alextekartik commented 2 years ago

Is this related to sembast? do you have some unit test/code to share to reproduce the issue?