Link Search Menu Expand Document

2. Data Import

Now that you’ve created your Atlas database, import the sample dataset using the mongorestore commandline utility:

  1. Get the sample data

    1. Get the code from https://github.com/WildAid/o-fish-realm
      git clone https://github.com/WildAid/o-fish-realm.git
      

      OR
      Download and extract the code

    2. 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.

    3. 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

  2. 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

  3. Get connection string
    1. Click CONNECT in the cluster itself (or as previously on the view that shows you all the clusters for the project):

    2. Click on Connect using MongoDB Shell, then “I have the mongo shell installed “

    3. Copy the connection string

    4. Click “Close”

    5. Paste the connection string into the “Atlas Cluster connection string” in your template.

  4. 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 after mongodb+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.”

  5. Verify with Data Explorer
    1. Go to Collections in the Atlas UI:

    2. Click on the BoardingReports collection and verify there are records:

  6. Add fulltext search index - Click on the “Search” tab, and then “Create Search Index”:

    1. Click “Create Index” to create the default fulltext search index, mapping every field.

    2. Click “Close” and your index will build in the background Great work, now you’re ready to hook up Realm…


Troubleshooting - Up to main build page