This is a step by step guide how to get up and running with Servers and Database. We will be using Node.js and MongoDB to run our server and store data.
There is a ton of information to break down so this workshop is broken down to 3 parts
Intro to servers and backend Workshop (presentation slides)
Databases 101 (presentation slides)
As with anything, you will need certain software downloaded to work with, luckily its not as bad as it looks at first
- NodeJS
- Postman (only needed for MongoDB Workshop)
- MongoDB (only needed for MongoDB Workshop)
- Studio 3T (only needed for MongoDB Workshop)
Need for all Workshops
We need to make sure you have at least version 6.11.0 which supports ES6. This workshop will use version 8.7.0 but anything above 6.11.0 for our purposes will be just fine!
- Go to NodeJS Download Page and download it
- Install
- Open terminal (Command prompt for Windows) and type
node -vand you should see a version
- If on Windows, you will also need to make sure
C:\Program Files\nodejs\is included in your Enviroment path- Note: The file path may vary for users
- If on Windows, you need to close and reopen command prompt to see effect
- Follow the package manager guide for your respected version of Linux
Need just for Express.JS and MongoDB Workshop
Postman is a tool used to call HTTP Request and see the response. This will be used to test that our server is correctly handling all various HTTP Request.
Need just for MongoDB Workshop
BIG NOTE - PLEASE READ MongoDB defaults its saved file path to /data/db (or C:\data\db for Windows). Create this folder unless you plan to change the path in the MongoDB configuration. If you don't do this MongoDB will complain and not start up!
When you download MongoDB you actually get a few different executables, we are worrying about just two: mongod and mongo
- Download and install MongoDB
- Look for "community edition", not "enterprise" or "atlas"
- Mac can use
brew install mongodb - For headless Linux you can run
sudo apt-get install mongodb-server
- Run
mongod --versionto confirm it install correctly
- If on Windows, make sure add path to MongoDB to system enviroment variables and restart the command prompt
- Location will be similar to
C:\Program Files\MongoDB\Server\3.0\bin\
- Open a terminal or command prompt and type
mongod- You might have to use
sudoif Mac/Linux
- You might have to use
- In a second terminal run
mongoand it should open a Mongo Shell - Run:
show dbsuse Testdb.TestCollection.insert({"hello":"world"})db.TestCollection.find()
- If this worked then you have a working MongoDB and to start it you just need to have
mongodrunning in background
Need just for MongoDB Workshop
Command line shells are good to learn, but for sake of simplicity we will just use a GUI to interact with our database. Studio 3T is by far the nicest MongoDB GUI I know about and easy to download and install.