Can't create a MongoDB Realm Sync in Development Mode - mongodb

I’ve got an iOS (swift) app that’s using a local realm. I’m trying to update it to use a synced realm so eventually I can make my app multi-user and share data. But I am new to MongoDB and Synced Realms.
I’ve successfully installed/build/run the “TaskTracker” starter “Synced” app on atlas and an iOS client.
Now I’m trying to make a Synced Realm for my app. I figure I would create a Synced Realm and put it in Development mode from scratch. That way I can convert my existing data into Synced data bit by bit and I don’t have to worry about the server side schema yet. I’m hoping that the schema will be defined for me and I can use it once I’m ready to move to a production level deployment.
So, I followed the “Get Started with Sync” document (https://docs.mongodb.com/realm/sync/get-started/). I’ve created my Atlas Cluster (Cluster0), and a Realm app in the web UI. The document says:
Navigate to the Realm Sync Panel
Decide whether to use Development Mode (I am).
Configure Sync:
In this step in the web UI, it seems that there are 3 steps:
Select a Cluster to Sync
Choose a Partition Key
Define a Database Name
For Step 1, I can select “Cluster0 - (Service: mongodb-atlas)”
However in Step 2 is where I get stuck: There is a dropdown that says “Enter a partition key field name…”, but when I select the drop down, it says “No options” and I cannot select anytthing. Therefore I can’t go to the third step or turn dev mode on.
The “Get Started with Sync” document doesn’t say anything about pre-populating the realm with data or schema (I thought that’s why I’m choosing Development Mode, so I can define my data on the fly until I figure out what the schema should be).
I even went back and created a database in the atlas cluster, but even after creating the database and a collection, the "Choose a Partition Key" dropdown still says "No actions".
I’m super stuck here. It’s likely because I don’t understand something. Can someone help me see the light?

OK, so I didn't realize this, but you can type into the dropdown box. So even though the drop down options say "No options", I can type in a partition key name "_partition" (or whatever). This is from a MongoDB person:
... On that screen, instead of using the dropdown, you can type in whatever field name you intend to use for the partition value. We generally use "_partition".

Related

Error CloudKit Dashboard - There was a problem loading the environment's status

Good day!
In CloudKit Dashboard I get the error:
There was a problem loading the environment’s status
This happens when I select the action "Deploy Schema to Production..." for the "Development" schema:
I have a released application using CloudKit (respectively, there are two working schemes - Development and Production). Before the release of the application, the Development schema in CloudKit Dashboard was translated into Production (Deploy schema to production).
Now I needed to make changes to the schema.
A new field and indexes for it, as well as indexes for an existing field, have been added to the Development schema.
Now I am trying to move the schema from Development to Production in CloudKit Dashboard (so that my changes show up in Production) and
this error persists, is there any other way you can update the Production schema or fix this error?
There can be a lot of strange errors in the CloudKit dashboard. Here are a few suggestions:
Try again later (and always do a hard refresh when you do). Sometimes the error is temporary.
Try in a different web browser. Support for Chrome has improved lately, but there were times when Safari was the only way to make certain things happen.
Create a new CloudKit container, rebuild your schema, and then try to deploy. I've had certain bugs never go away within a particular container and I've had to start over fresh.
If the issue persists, submit a Feedback to the CloudKit team. They have fixed things within a day or two for me in the past.
Aside from that, your particular error isn't terribly descriptive and it's most likely something on Apple's end.
I found out that it runs into a client-side timeout of 1 minute, but the server takes longer. You can kill the timeout with
var id = window.setTimeout(function() {}, 0);
while (id--) {
window.clearTimeout(id); // will do nothing if no timeout with id is present
}
For details, see https://stackoverflow.com/a/67862078/

How do I set up MongoDB Atlas?

I need to work with MongoDB Atlas but unsure how to set it up? I have never used Cloud DB before. I want to make sure that I can let everyone connect to it without an API Key
Sign up with MongoDB Atlas
Go to the MongoDB Atlas website and sign up: https://www.mongodb.com/cloud/atlas
Fill in the form to create your account:
Once you are in, it will ask you to select a path for clustering. Select the Free option at this time.
Then it will ask you to create a starter cluster
All default settings are fine
Encourage you to rename your cluster and then Click Create
After about a minute, it’s created
Click on Collections button
For first time use it will ask if you want sample data
If you just need sample data to play with, click on Load a Sample Dataset
For that, just follow the prompts
All your data will load
Next click on Database Access, we will need to create a database user
Keep it easy, use a password and select the role that this user should have
Click Add User
Now we need to white List IPs
Click on Network Access
Then click on Add IP, then "allow access from anyone" (No need for API Key)
You can always change this later but for testing purposes, you can select this
Click Confirm
Wait until it states that it’s active
Now click on Cluster and Connect
Select Connect using MongoDB Compass
Leave settings as is and copy the string and make the changes
For our purposes, here is our connection string.
mongodb+srv://Cam_user:Password1#camcluster.l41xe.mongodb.net/sample_airbnb

High Availability AEM Author

I’ve been working with AEM for over a year now and lately I’ve been trying to move into a high availability setup for author.
My problem is when ever I spin up a server, add sites, and spin up another server the data doesn’t persist to the new instance. I know why this doesn’t work in the traditional setup (repository is stored locally on the file system). However, I’ve attempted using the S3 backend, and it results in the same problem where the data doesn’t persist onto the new instance.
Ive read about using mongoMK (https://helpx.adobe.com/experience-manager/6-3/sites/deploying/using/recommended-deploys.html), I.e. mongodb as a store, but they also recommended using S3 as the backend.
My question is, does anyone have any experience with multiple AEM author instances sharing the same data and node stores, if so do you have any suggestions as to how to get this working or resources where I can read about this?
After further research it seems the only option for backend clustering is to use mongodb. My attempts to use mongodb with AEM as a backend have failed. When I attempt to use the crx3 and crx3mongo run modes it looks like AEM hangs after opening a connection to mongo. I have verified that nothing is getting placed into the DB via a show dbs returning 0.000GB for the corresponfing database.

Core Data syncronization procedure with Web service

I'm developing an application that needs to be syncronized with remote database. The database is connected to the a web-based application that user able to modify some records on the web page.(add/remove/modify) User also able to modify the same records in mobile application. So each side (server - client) must be keep the SAME latest records when an user press the sync button in mobile app. Communication between server and client is provided by Web Serives.(SOAP) and i am not able to change it because of it is strict requirements. (i know this is the worst way that can be used). And another requirement is the clients are not able to delete the server records.
I already be familiar with communicating web service (NSURLConnection), receiving data (NSData) and parsing it. But i could not figure out how the syncronization procedure should be. I have already read this answer which about how i can modify server and client sides with some extra attributes (last_updated_date and is_sync)
Then i could imagine to solve the issue like:
As a first step, client keeps try to modify the server records with sending unsyncronized ones. New recoords are directly added into DB but modified records shoud be compared depending on last_updated_date. At the end of this step, server has the latest data.
But the problem is how can manage to modify the records in mobile app. I thought it in a two way:
is the dummiest way that create a new MOC, download all records into this and change with existing one.
is the getting all modified records which are not in client side, import them into a new MOC and combine these two. But in this point i have some concerns like
There could be two items which are replicated (old version - updated version)
Deleted items could be still located in the main MOCs.
I have to connect multiple relationships among the MOCs. (the new record could have more than 4 relationships with old records)
So i guess you guys can help me to have another ideas which is the best ??
Syncing data is a non-trivial task.
There are several levels of synchronization. Based on your question I am guessing you just need to push changes back to a server. In that case I would suggest catching it during the -save: of the NSManagedObjectContext. Just before the -save: you can query the NSManagedObjectContext and ask it for what objects have been created, updated and deleted. From there you can build a query to post back to your web service.
Dealing with merges, however, is far more complicated and I suggest you deal with them on the server.
As for your relationship question; I suggest you open a second question for that so that there is no confusion.
Update
Once the server has finished the merge it pushes the new "truth" to the client. The client should take these updated records and merge them into its own changes. This merge is fairly simple:
Look for an existing record using a uniqueID.
If the record exists then update it.
If the record does not exist then create it.
Ignoring performance for the moment, this is fairly straight forward:
Set up a loop over the new data coming in.
Set up a NSPredicate to identify the record to be updated/created.
Run your fetch request.
If the record exists update it.
If it doesn't then create it.
Once you get this working with a full round trip then you can start looking at performance, etc. Step one is to get it to work :)

Overwrite database or update (iPhone)?

I have a content based, read-only iPhone app. Users can select favorite topics, which I need to track. Some topics I'd like to make available between app updates through the App Store. I'll need to track if users have downloaded these particular topics or not until the App Store update is available. This approach will consist of two tables for user tracking. All other tables contain mainly static content, save any new downloaded entries.
Before I began tracking user content, I'd always deploy the database on app updates. An overwrite - simple. But now I need to track certain user configurations. Rather than trying to keep track of which app version a user has and running through a list of sql scripts in the correct order, so the user is at the right database version, I'm thiking to use two databases. One contains static content and the other user data. The static content database is always overwritten. That keeps things simple. The database currently is 250kb. It will grow very slowly.
I have plans to use SDK 3.0 push notification and peer-to-peer as well, which will store any user config data in the user database.
Any one see problems with this approach?
This sounds alright to me. If you're using SQLite, you may want to look into the ATTACH DATABASE command, which lets you keep two databases open on the same connection.