0
我已經創建了一種管理所有用戶之間的共享表的方法,但是我看不到此表。我剛剛刪除了「〜」字符,如果我離開「〜」字符,但它只有所有者才能看到的表,它就會起作用。我不知道爲什麼它不起作用。也許這不是在用戶之間共享表格的正確方式?無法在Realm對象服務器上看到數據庫
static public func setGlobalDatabase(database:String, completion: @escaping (_ realm: Realm?, _ error: Error?) -> Void) {
let realmPath = RealmService.REALM_SERVER_DATA + "/" + ConstanteService.APP_DOMAINE + "-" + database
let user = SyncUser.current
if user == nil {
SyncUser.logIn(with: .usernamePassword(username: RealmService.username, password: RealmService.password, register: false), server: URL(string: RealmService.REALM_SERVER_HTTP)!) { user, error in
guard let user = user else {
completion(nil, error)
return
}
DispatchQueue.main.async {
// Open Realm
let configuration = Realm.Configuration(syncConfiguration: SyncConfiguration(user: user, realmURL: URL(string: realmPath)!))
let permission = SyncPermissionValue(realmPath: realmPath, // The remote Realm path on which to apply the changes
userID: "*", // The user ID for which these permission changes should be applied
accessLevel: .write) // The access level to be granted
user.applyPermission(permission) { error in
if let error = error {
// handle error
return
}
// permission was successfully applied
}
completion(try? Realm(configuration: configuration), nil)
}
}
}
else{
DispatchQueue.main.async {
// Open Realm
let configuration = Realm.Configuration(syncConfiguration: SyncConfiguration(user: user!, realmURL: URL(string: realmPath)!))
completion(try? Realm(configuration: configuration), nil)
}
}
}