领域错误域=io.realm.unknown Code=89 “操作已取消" [英] Realm Error Domain=io.realm.unknown Code=89 "Operation canceled"

查看:55
本文介绍了领域错误域=io.realm.unknown Code=89 “操作已取消"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果这是 URL 问题,我不知道.一切正常,但在尝试异步打开领域时,出现域错误.

I don't if this is a URL issue. Everything works fine but when trying to Async open the realm, I get a domain error.

我的数据存储在数据库 Store.items 中.这是我的屏幕截图

My data is stored in a database Store.items. Here is my screen shot

我想将服务器数据同步到我的本地领域数据库.这是我的代码

I want to sync to server data to my local realm database. here is my code

我有一个 Constants.swift 文件

I have a Constants.swift file

import Foundation
 
struct Constants {
    // **** Realm Cloud Users:
    // **** Replace MY_INSTANCE_ADDRESS with the hostname of your cloud instance
    // **** e.g., "mycoolapp.us1.cloud.realm.io"
    // ****
    // ****
    // **** ROS On-Premises Users
    // **** Replace the AUTH_URL string with the fully qualified versions of
    // **** address of your ROS server, e.g.: "http://127.0.0.1:9080"

    static let MY_INSTANCE_ADDRESS = "app.us1a.cloud.realm.io" // <- update this

  
    static let AUTH_URL  = URL(string: "https://\(MY_INSTANCE_ADDRESS)")!
    static let REALM_URL = URL(string: "realms://\(MY_INSTANCE_ADDRESS)/appName")!

    
    



}

 
    override func viewDidLoad() {
        super.viewDidLoad()
       
        SyncServertoLocal()
        
        }


    @objc func SyncServertoLocal(){
        print("trying to sync")
        let config = SyncUser.current?.configuration(realmURL: Constants.REALM_URL, fullSynchronization: true)
              Realm.asyncOpen(configuration: config!) { realm, error in
                         if let realm = realm {
                             // Realm successfully opened, with all remote data available
                             print("Remote data available")
                             
                         } else if let error = error {
                             // Handle error that occurred while opening or downloading the contents of the Realm
                            
                            print("Opps we have a realm problem", error)
                            
                         }
                     }
              
    }

Opps 我们有一个领域问题 Error Domain=io.realm.unknown Code=89 操作已取消"UserInfo={Category=realm.basic_system, NSLocalizedDescription=操作取消,错误代码=89}

Opps we have a realm problem Error Domain=io.realm.unknown Code=89 "Operation canceled" UserInfo={Category=realm.basic_system, NSLocalizedDescription=Operation canceled, Error Code=89}

似乎没有数据正在同步,但我不知道错误意味着什么以及如何修复它.如何修复错误?

it appears like no data is syncing but I don't know what the error means and how to fix it. How can I fix the error?

推荐答案

主要问题是您将现有的 Realm Sync 文档与 BETA MongoDB Realm 文档混合在一起 - 显然是一个常见问题.

The main issue is that you're mixing the existing Realm Sync documentation with the BETA MongoDB Realm Documentation - apparently a common issue.

两者的设置不同,您不能使用 MongoDB Realm 控制台访问您的 Realm Sync 数据库 - 它只能与 BETA MongoDB Realm 一起使用.

The setup is different between the two and you cannot use the MongoDB Realm console to access your Realm Sync database - it can only be used with the BETA MongoDB Realm.

这里是 MongoDB Realm Sync 文档请注意,您的对象需要具有与控制台上设置的分区键匹配的分区键.另外,连接顺序不同,看起来更像这样,包括分区和省略fullSync(和其他)

Here's the MongoDB Realm Sync docs noting that your objects need to have a partition key that matches the one set up on the console. Additionally, the connection sequence is different and looks more like this, including the partition and omitting fullSync (and others)

let user = app.currentUser()
let partitionValue = "myPartition"
Realm.asyncOpen(configuration: user.configuration(partitionValue: partitionValue),

您问题中的代码适用于经典"和当前领域同步.如果您想坚持使用 Realm Studio 应用程序,您可以访问您的 Realm Sync非测试版领域.

The code in your question is for the 'classic' and current Realm Sync. You can access your Realm Sync with the Realm Studio app if you want to stick with the non-beta Realm.

另请注意,处理对象也略有不同,因为您需要包括每个对象的分区值.例如,使用 MongoDB Realm,添加一个任务对象就是这样的代码

Also note that working with objects is slightly different as well because you need to include the partition value for each object. For example, with MongoDB Realm, adding a task object would be this code

try! realm.write {
  realm.add(Task(partition: partitionValue, name: "My task"))
}

然而,经典的 Realm 只是

Whereas, with classic Realm its just

try! realm.write {
  realm.add(Task(name: "My task"))
}

这篇关于领域错误域=io.realm.unknown Code=89 “操作已取消"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆