Migrate Realm 2.x List of Object to Realm 3.x List of String (or other primary type)

Migrate Realm 2.x List of Object to Realm 3.x List of String (or other primary type)

By : Ishuk Choudhary
Date : November 20 2020, 03:01 PM
With these it helps Realm 3.0 introduces List of primitives types (String, Int, …). , You will need to convert the list of Cities to a list of Strings:
code :
if oldSchemaVersion < 2 {
  migration.enumerateObjects(ofType: Map.className(), { (oldObject, newObject) in
    newObject!["cities"] = (oldObject!["cities"] as! List<MigrationObject>).value(forKey: "name")

Share : facebook icon twitter icon
Realm: what happens if we update primary key of a realm object?

Realm: what happens if we update primary key of a realm object?

By : yogijerry
Date : March 29 2020, 07:55 AM
Does that help In your source code, the user actually is still standalone object after calling realm.copyToRealm(user).
You should give the return value to user like user = realm.copyToRealm(user);, then the user will be managed by Realm.
Realm Migration: Migrate an object into a List

Realm Migration: Migrate an object into a List

By : abdu
Date : March 29 2020, 07:55 AM
Any of those help So, I've been trying to migrate my Realm schema, but I can't seem to do the following. , You can run a migration block under Realm Configuration.
code :
Realm.Configuration.defaultConfiguration = Realm.Configuration(
schemaVersion: 2,
migrationBlock: { migration, oldSchemaVersion in

    migration.enumerate(Period.className()) { oldObject, newObject in
        // filter the versions where this change would take place
        // if oldSchemaVersion < 1 {
        // }...
        newObject["weekdays"] = [oldObject["weekday"]]              
Realm - Inner realm list object is not updated after copyToRealmOrUpdate()

Realm - Inner realm list object is not updated after copyToRealmOrUpdate()

By : Louis zhang
Date : March 29 2020, 07:55 AM
help you fix your problem Ehm no realm doesn't work this way. I don't really know how it interacts with lists but try the first solution, if it doesn't work the second one will definitely do:
code :
 realm.executeTransaction(new Realm.Transaction() {
    public void execute(Realm realm) {
        RealmList<Message> nestedMessages = initialMessage.getNestedMessages();
        newMessage = realm.copyToRealmOrUpdate(newMessage);
RealmList<Message> nestedMessages = new RealmList<Message>();
RealmList<Message> oldMessages = initialMessage.getNestedMessages();
for(Message message: oldMessages){
newMessage = realm.copyToRealmOrUpdate(newMessage);
User made from Realm object has same Primary Key Realm

User made from Realm object has same Primary Key Realm

By : Ray
Date : March 29 2020, 07:55 AM
it helps some times Realm is an object database, so you need to create a new object every time:
code :
try! realm.write {

    user = User() // Create a new user instance

    user.userName = userNameTextField.text!
    user.passWord = passWordTextField.text!
    user.email = emailTextField.text!
    user.name = fullNameTextField.text!
    user.age = ageTextField.text!
    user.id = UUID().uuidString


Transform object to list[object] in Realm ( How can i replace a list[objects] with object field in Realm? )

Transform object to list[object] in Realm ( How can i replace a list[objects] with object field in Realm? )

By : maleficarium
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , I created new issue in Realm GitHub then i found right way for transform object to list[object] in Realm and insert existing object from previous version to new version of application.
In this example we want to transform Token object to tokenList[Token] in Bank model.
code :
public class RealmMigration implements io.realm.RealmMigration {




        if (oldVersion == 3) {
            //Create a schema for Bank
            final RealmObjectSchema bankSchema = realmSchema.get("Bank");
            //Create a schema for Token that has been in Bank model
            final RealmObjectSchema tokenSchema = realmSchema.get("Token");
            //We use bankSchema for add tokenList field and transform
                .addRealmListField("tokenList", tokenSchema)
                .transform((obj) -> {//obj is bank model,we have a transform in bank model
                         DynamicRealmObject token = obj.get("Token");
                         List<DynamicRealmObject> tokenList = obj.get("tokenList");
                                //We add token from pre version to tokenList in new version
                                if (token != null) tokenList.add(token);
                    //Finally remove unwanted field
Related Posts Related Posts :
  • Artefact in shader for iOS
  • Make async request in table view delegate method
  • (iOS) Escaping single quote in XML
  • Change the UIButton Image when tapped multiple times
  • Convert string JSON response to a boolean using Swift 4 Decodable
  • [iOS]renew push certificate but don't have certificateSigningRequest file
  • How to change src value in UIWebView?
  • Inserting into Array and comparing Dates Swift iOS Code
  • IBDesignable UI is not showing in Xcode 9 with Swift
  • Ask for only Request Always Authorization, and not When-In-Use Authorization
  • "Google/Analytics.h file not found" after updating pod to GoogleAnalytics
  • Post request with HTTP header parameters
  • Managing cookies for a domain in Associated Domains
  • Array items showing error in IOS
  • Saving asynchronously downloaded files' contents to SQLITE
  • Swift 4 - animating both alpha and constraint affects other components alpha value
  • UIView animation in completion block starts with displacement
  • List all Apps and Track Internet Usage
  • Handling Back To Back HTTP Posts SWIFT 4.0
  • Azure App Service Push - registration endpoint
  • Select multiple item in a tableView
  • Apartment number / Unit number returned from google places api
  • How to align UICollectionViewCells from left to right?
  • How can I add search option on UIPickerview in ios?
  • Scenekit - physicsWorld setup to prevent kinematic nodes to intersect
  • Carthage Build Failed
  • swift 3, ios 10 - push notification firebase is not received
  • App Xcode 8 to Xcode 9 - Prevent Auto Hide Status Bar
  • How to pop back to a TableViewController?
  • Is UserDefaults thread safe in Swift? How to check it?
  • UISwitch in a table selects multiple cells when switch state on
  • iOS App with no story board (Size classes and Device type limitations)
  • AudioKit issue, mic not sensitive enough
  • send indexpath to Firebase (like button)
  • UIColor saturation brightness values different from the regular saturation luminosity values of a color
  • JSON: Extracting Data Using Alamofire and Swift 3
  • invalid_grant on OAuth2 request when obtaining access_token from SSO in App
  • ABNewPersonViewController using contact framework
  • Design iOS button scalable
  • Subclassing NSLayoutConstraint constant based on screen height
  • Using BLE RSSI value for connect-by-proximity
  • Backgroundcolor of NSTextfield
  • Firebase modifying uid in every view
  • How to rotate orientation?
  • Upload a new version of ios app to app store?
  • UIScrollView do not scroll down to its original position when keyboard disappear
  • What is the most effective way of tracking time/dates in an iOS/Swift application?
  • WatchKit get user's preferred handedness
  • Location permission dialog is shown and immediately disappears
  • Combine these regex expressions
  • How to save an array of HKQuantitySamples (heart rate) to a workout
  • RestKit mapping with parent key as attribute and key contains parenthesis
  • How to add UITextField programmatically to UIScrollView without breaking constraints?
  • How to make a view height grow depending on its child views contents
  • Some users experiencing NSInternalInconsistencyException crash
  • Mark successful siesta response as error
  • Using a modified PDFTron Tools Framework
  • How can I use universal links when I call openURL inside my own app?
  • NSArray of doubles iOS (Objective c)
  • Passing data from embedded PageViewController to parent View Controller
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org