objectbox / objectbox-swift

Swift database - fast, simple and lightweight (iOS, macOS)
https://swift.objectbox.io
Apache License 2.0
452 stars 30 forks source link

ConflictStrategy.REPLACE #56

Closed jonasrotilli closed 2 years ago

jonasrotilli commented 2 years ago

In the android version, together with the Unique annotation, we have the option to define the Overlay strategy @Unique(onConflict = ConflictStrategy.REPLACE). It needs to have this same option for Swift. If it exists, it is not documented, please show us.

jonasrotilli commented 2 years ago

No comments, no predictions?

This is very important, since there is no ID of type string, a strategy to overcome this problem of not having ID of type String would be to add another attribute and put unique in it and every time you repeat, replace.

greenrobot commented 2 years ago

Actually, this is worked on right now. A release should follow this week.

jonasrotilli commented 2 years ago

@greenrobot did this function work? Can you tell us roughly when it will be available?

Thanks for helping to solve this, it will be very useful!

greenrobot commented 2 years ago

@jonasrotilli Sorry, we're having some packaging / Carthage issues delaying the release; it might become next week...

greenrobot commented 2 years ago

1.7.0-rc2 just landed on Cocoapods; here's a usage example:

// objectbox: unique = { "onConflict": "replace" }
var stringId: String = ""
greenrobot commented 2 years ago

1.7.0 is now released.

jonasrotilli commented 2 years ago

It must have been really good! Thank you! Unfortunately I won't be able to use it, because on my MacOS Catalina the xCode only goes up to 12.2 and these latest updates are in xCode 12.5.

greenrobot commented 2 years ago

Oh, not good. So, you want to stick to Catalina?

jonasrotilli commented 2 years ago

Not by choice, it's just that apple didn't make bigSur available for older macs, which is my case...