Now that you’ve created your Atlas database, import the sample dataset using the mongorestore
commandline utility:
-
Get the sample data
- Get the code from https://github.com/WildAid/o-fish-realm
git clone https://github.com/WildAid/o-fish-realm.git
-
Go into the o-fish-realm directory, “o-fish-realm” if you did a git clone in the previous step, or “o-fish-realm-main” if you downloaded and extracted the code. The directory should have at least these 3 items: README.md, WildAidDemo, and WildAidSampleBackup.
- Note the path to the directory WildAidSampleBackup. Put it in the “Path to sample data” section of the template.
Example:/Users/sheeri/o-fish-realm/WildAidSampleBackup
- Get the code from https://github.com/WildAid/o-fish-realm
-
Note the path to the directory WildAidDemo, and put it in the “Path to Realm code” section of the template.
Example:/Users/sheeri/o-fish-realm/WildAidDemo
- Get connection string
- Click CONNECT in the cluster itself (or as previously on the view that shows you all the clusters for the project):
- Click on Connect using MongoDB Shell, then “I have the mongo shell installed “
- Copy the connection string
- Click “Close”
- Paste the connection string into the “Atlas Cluster connection string” in your template.
- Click CONNECT in the cluster itself (or as previously on the view that shows you all the clusters for the project):
- In a terminal window, use the mongorestore utility to import the data you got in the first step. use the
mongorestore
utility and the “Path to sample data”, and the “Atlas Cluster connection string”. Modify the connection string - just aftermongodb+srv://
you should put in the “Atlas Cluster Admin username” from the template, followed by @ and then the rest of the mongodb+srv link. The whole string, replace what’s in all capital letters:mongorestore --drop --uri "mongodb+srv://USERNAME@REST_OF_CONNECTION_STRING" PATH_TO_BACKUP
Example:
mongorestore --drop --uri "mongodb+srv://admin@ofish-xxxxx.mongodb.net/" /Users/sheeri/wildaid_demo/o-fish-realm/WildAidSampleBackup
Note, if you run the
mongorestore
command from inside of the o-fish-realm directory, then you can use a relative path for PATH_TO_BACKUP, like this:mongorestore --drop --uri "mongodb+srv://admin@ofish-xxxxx.mongodb.net/" ./WildAidSampleBackup
When it is successful, you will see a message like:
“6117 document(s) restored successfully. 0 document(s) failed to restore.” - Verify with Data Explorer
-
Go to
Collections
in the Atlas UI: -
Click on the BoardingReports collection and verify there are records:
-
- Add fulltext search index - Click on the “Search” tab, and then “Create Search Index”:
- Click “Create Index” to create the default fulltext search index, mapping every field.
- Click “Close” and your index will build in the background Great work, now you’re ready to hook up Realm…
- Click “Create Index” to create the default fulltext search index, mapping every field.