What is the difference between MongoDB Atlas and Realm Sync? The following tutorial shows using documents to do CRUD operations, this makes sense to me. https://www.mongodb.com/docs/atlas/device-sdks/sdk/swift/app-services/mongodb-remote-access/
let queryFilter: Document = ["name": "Americano"]
let findOptions = FindOptions(0, nil, [["beanRegion": 1]])
collection.find(filter: queryFilter, options: findOptions) { result in
switch result {
case .failure(let error):
print("Call to MongoDB failed: (error.localizedDescription)")
return
case .success(let documents):
print("Results: ")
for document in documents {
print("Coffee drink: (document)")
}
}
}
That feels pretty straight forward. There are clear commands for adding and deleting data and accessing specific documents. However, then there is flexible sync:
https://www.mongodb.com/docs/atlas/app-services/tutorial/swiftui/
let config = user.flexibleSyncConfiguration(initialSubscriptions: { subs in
if let foundSubscription = subs.first(named: Constants.myItems) {
foundSubscription.updateQuery(toType: Item.self, where: {
$0.owner_id == user.id && $0.priority <= PriorityLevel.high
})
} else {
// No subscription - create it
subs.append(QuerySubscription<Item>(name: Constants.myItems) {
$0.owner_id == user.id && $0.priority <= PriorityLevel.high
})
}
}, rerunOnOpen: true)
This I found confusing because you do not have any specific write commands, you just add data to an observable object. So are these two used together? or are they built for different needs?
What it looks like to me, is that flexible sync is when a user might need to see other users data, very quickly. For instance, flexible sync would make a lot of sense for a messaging app. For a private blog app where you only see your own posts, however, it feels like this may not be necessary.