Skip to content

Instantly share code, notes, and snippets.

@acidtone
Last active September 13, 2024 19:56
Show Gist options
  • Save acidtone/d290d63873b07ffd871cafa39f917c1f to your computer and use it in GitHub Desktop.
Save acidtone/d290d63873b07ffd871cafa39f917c1f to your computer and use it in GitHub Desktop.
MongoDB Atlas: Import data using MongDB Compas

MongoDB: Importing data into MongoDB Atlas

Pre-requisites

Instructions

  1. Create a json file containing the data you'd like to import (like the local module you're creating for Assignment 5).
    • Warning: MongoDB (and mongoose) assume you'll be importing an array of objects. Any other data types will lead to unexpected results.
    • A sample definitions.json file has been provided with this Gist.
  2. Add your connection string in Compass.
    • MongoDB Atlas will create a starter for you, which you will modify with your db login and database name.
  3. Create a Database.
    • It's often best to give your database a general name such as projects or the name of your app.
  4. Create a Collection (plural noun like animals or images).
    • Name your collection definitions if you're using the definitions.json sample data.
  5. Click "Import Data" and upload your json file.
  6. Done! You're now ready to query your data.
[
{
"term":"Global",
"definition":"All code that is not inside a function. ",
"slug":"global"
},
{
"term":"Global Execution Context",
"definition":"The environment that is available everywhere in your app.",
"slug":"global-execution-context"
},
{
"term":"Lexical Environment",
"definition":"Where something sits physically in the code you write. In Javascript, *where* you write your code is important",
"slug":"lexical-environment"
},
{
"term":"Syntax Parser",
"definition":"A program that reads your code and determines what it does and if its grammar is valid",
"slug":"syntax-parser"
},
{
"term":"Execution Context",
"definition":"A wrapper to help manage the code that is running. The lexical environment that is currently running is managed via execution contexts.",
"slug":"execution-context"
},
{
"term":"Variable Environment",
"definition":"Where a named value lives.",
"slug":"variable-environment"
},
{
"term":"Name/Value Pair",
"definition":"A name which maps to a unique value.",
"slug":"name-value-pair"
},
{
"term":"Primitive Type",
"definition":"A Type of data that represents a single value.",
"slug":"primitive-type"
},
{
"term":"Operator",
"definition":"A special function that is syntactically written differently. Generally, operators take two arguments and return one result.",
"slug":"operator"
},
{
"term":"Operator Precedence",
"definition":"Which operator function gets call first (i.e. BEDMAS).",
"slug":"operator-precedence"
},
{
"term":"Operator Associativity",
"definition":"What order operator functions get called in. left-to-right or right-to-left.",
"slug":"operator-associativity"
},
{
"term":"Expression",
"definition":"A piece of code that returns a value.",
"slug":"expression"
},
{
"term":"Coersion",
"definition":"Converting a value from one type to another.",
"slug":"coersion"
},
{
"term":"Object",
"definition":"A collection of name/value pairs (in terms of Javascript).",
"slug":"object"
},
{
"term":"First-class Function",
"definition":"Everything you can do with other types, you can do with functions.",
"slug":"first-class-function"
},
{
"term":"Callback",
"definition":"A function passed to another function , which we assume will be invoked at some point.",
"slug":"callback"
},
{
"term":"Error-first Callback",
"definition":"Callbacks that take an error object as their first parameter. `null` if no error, otherwise this will be an object containing our error.",
"slug":"error-first-callback"
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment