I am developing an iOS application using the realm-cocoa SDK. I am using the Realm Cloud as a backend for my production environment.
I cannot create a partial sync subscription if I log in the app as an admin user in a production environment.
No error message is displayed, but it remains pending all the time. If I turn off the admin flag from Realm Studio and log in again, I can create subscriptions.
When migrating our instance from partial sync to full sync, we need to retrieve and modify the data for all our users.
Is it possible to log in as an administrator user from the client SDK and operate the data of our users?
Client SDK version is realm-cocoa 3.21.0.
let partialSyncRealm = RealmClient.shared.getPartialSyncRealm()
searchResults = partialSyncRealm.objects(UserData.self)
subscription = searchResults!.subscribe(named: SyncSubscriptionType.SearchUsers.getName())
subscriptionToken = subscription.observe(\.state, options: .initial) { state in
if state == .complete {
// self.activityIndicator.stopAnimating()
// This is never called when I login the app as admin user
} else {
print("Subscription State: \(state)")
>> creating
>> pending
}
}
notificationToken = searchResults!.observe { [weak self] (changes) in
guard let tableView = self?.table else { return }
switch changes {
case .initial:
tableView.reloadData()
case .update(_, let deletions, let insertions, let modifications):
tableView.beginUpdates()
tableView.insertRows(at: insertions.map({ IndexPath(row: $0, section: 0) }),
with: .automatic)
tableView.deleteRows(at: deletions.map({ IndexPath(row: $0, section: 0)}),
with: .automatic)
tableView.reloadRows(at: modifications.map({ IndexPath(row: $0, section: 0) }),
with: .automatic)
tableView.endUpdates()
case .error(let error):
fatalError("\(error)")
}
}
This is not an answer but you shouldn’t be using a Query Based Sync (partial sync) solution going forward as that’s looks like it’s going to be depreciated (note there’s not official word on this).
Query-based Sync is not recommended. For applications using Realm Sync, we recommend Full Sync. Learn more about our plans for the future of Realm Sync here
Question: Can you share the code you’re using to log into the app as an Admin user?
My understanding is that MongoDB Realm doesn’t support partial sync in public beta, but seems to support partial sync in the GA phase.
There are specific Realm Cloud features that will not be integrated into MongoDB Realm during the public beta phase:
Query-based Sync : MongoDB Realm will require this feature to be re-architected to maximize scalability and performance. MongoDB Realm will initially focus on full sync and within the GA phase we expect to re-architect query-based sync to be fully optimized for MongoDB Realm.
In the second half of 2020, we expect to make the architecture and performance improvements that will allow us to bring MongoDB Realm from beta to GA.
At this point, we’ll begin work on key features like:
Bringing the functionality of Query Based Sync into MongoDB Realm by rewriting the feature to make it fully optimized for the new architecture.
The code I’m using to login to the app as an Admin user is below.
func login(email : String , password : String, successCallback : @escaping (SyncUser)->Void, failCallback : @escaping (Error?)->Void) {
let creds = SyncCredentials.usernamePassword(username: email, password: password, register:false)
SyncUser.logIn(with: creds, server: RealmConstants.AUTH_URL, onCompletion: { (user, err) in
if let error = err {
failCallback(error)
} else if let syncUser = user {
successCallback(syncUser)
}
})
}
Thanks for sharing that info - I was aware of the original timeline and am surprised it’s not been refreshed with more a more current timeline. IMO, based general chat and some discussion groups, the whole project is about a year behind that initial time-frame. I could be totally wrong and it may be right on schedule - any of you Realm’ers out there feel free to chime in. Of course ‘the second half of 2020’ is a 6 month window, so who knows.
It looks like you’re using the standard log in… Did you create an administrator role (not ROS admin) and add yourself (assuming you’re the admin) to that role? Also, have you already set up ACL’s and if so, what do they look like.
We’re able to access users data here so just trying to clarify how yours is set up.
Did you create an administrator role (not ROS admin) and add yourself (assuming you’re the admin) to that role?
Maybe my understanding was insufficient.
Was it just not enough to change the “Role” item from “RegularUser” to “Administrator” from the Realm Studio user list? Could you please tell me about the above procedure?
The Role created by default is set for all PermissionUsers.
Also, all users belong to the “everyone” role.
That’s a little unclear. Are you able to access the data when you log in as an Admin? If so, and you log into Realm Studio and add a Regular user to a role that has access to that data, are you saying they cannot access it?
Maybe in you include some screen shots from Realm Studio about how your permissions are set up, it would be more clear. _Class, _Permission and _Realm and maybe _Role would be relevant.
In preparation for our new product launch. We hope that you’ll be pleased with the integration - feel free to email me at ian.ward@mongodb.com for more details
@Ian_Ward Great news! I hope the project remains on track.
Unfortunately Realm has become almost unusable with the 5.0.0 release as Realm Studio no longer works and simple filters are returning inaccurate results (amongst a myriad of other issues that didn’t previously exist). Yes, tickets are open with no response for a number of days.
It’s all moving forward but unless the existing issues are rectified it’s going to be a rough ride.
OP: Since we’ve upgraded to 5.0.0 Realm Studio no longer works so we can’t duplicate your exact settings. We were going to toggle the admin flag but can’t do that currently via RS.
However, our Query Based Sync app continues to work and our Admin can in fact see and work with other users data so we can’t duplicate the issue you describe
Perhaps the issue lies elsewhere in your code - is it possible the data you’re attempting to access is stored locally on the users device and not sync’d? Can you see it in Realm Studio (if yours is still working)?