realm-java
realm-java copied to clipboard
UNIQUE
How to determine the class that the field name unique? Just as Primary keys?
Yes, so far that's the only way, but we're considering to support some kind of annotation for field value uniqueness
Just to be curious. Do you have a use case for this that isn't already covered by using @PrimaryKey?
The problem was solved. Only after the introduction of a unique field in the table, we had to alter the program logic. There were: realm.beginTransaction(); Authors author = realm.createObject(Authors.class); author.setUrl_base("pptr"); realm.commitTransaction(); Now: Authors author = new Authors(); author.setUrl_base("pptr"); realm.beginTransaction(); realm.copyToRealmOrUpdate(author); realm.commitTransaction(); Very unfortunate that because of one field had to rewrite the code.
That happens because you don't set your unique field. If you did you would not have to use standalone objects
Ok.
@emanuelez sorry I'm confused, would you mind giving a little code snippet of what you are talking about?
But I cited above code that used prior to the introduction to the table a unique field, and after it. Now you have to write one line of code to add more new rows to a table.
SQLite also has different modes for conflict resolution when it comes to uniqueness constraints we can consider: https://www.sqlite.org/lang_conflict.html
:+1: waiting for this enhancement :)
@beeender @cmelchior Is this feature coming anytime soon?
Realm is lacking important feature. realm even has no compound key. so we have to calculate compound key manually.so in practical development, realm is useless. Realm has no roadmap.so don't expect anything.
@cmelchior now that Primary Keys also imply that the value cannot be changed once persisted, is there a chance for a @Unique constraint which doesn't force you into the "value cannot be changed once persisted" limitation?
+1
+1
+1
+1
Any news on this, I'm still waiting for this feature
+1
I want to make field 'itemName' of Table Item to be unique in Android Realm. It means 'itemName' should not contain duplicate values. Is there any other way to achieve this except Primary key.. Thanks..
+1
Check is possible reliably in transaction if count > 0
+1
+1
+1
+1
+1
+1
+1
+1, and i need it on realm-cocoa too.
+1