-
Notifications
You must be signed in to change notification settings - Fork 146
Closed
Labels
enhancementNew feature or requestNew feature or request
Milestone
Description
I am new to Objectbox, but it seems to fit to my needs, except for one thing: upsert data.
I fetch some items to my API server (300 items) and they have a UUID, with @unique. Sometimes, these items are updated and I would like to fetch/update them, by their UUID.
FYI this is what I'm doing currently, I don't know if it's the best way:
List<CardModel> cards;
cards.forEach((card) {
card.extension.target = extension;
CardModel? cardInDb = _cardRepository.findByUuid(card.uuid);
if (cardInDb != null) {
card.id = cardInDb.id;
}
});
_cardRepository.box.putMany(cards);After some researches, I've seen that Objectbox Java has a OnConflict flag for @unique:
@Unique(onConflict = ConflictStrategy.REPLACE)
See objectbox/objectbox-java#509
It would be great if we have the same thing in Dart/Flutter.
stnokott, syncer, jecsan and greenrobot-team
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request