DEV Community

Mark Kop
Mark Kop

Posted on • Edited on

2

Fullstacking: Setting up MongoDB

This is part of a full-stack challenge.
Let's start by trying to make all layers working by themselves: React Native, NodeJS + KoaJS and MongoDB.
In this tutorial we'll be setting up MongoDB following these instructions on Ubuntu 18.04

MongoDB

Import the MongoDB public GPG Key:
wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc | sudo apt-key add -

Create a list file:
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.2.list

Reload the local package database
sudo apt update

Install the latest stable version
sudo apt-get install -y mongodb-org

Start MongoDB
sudo service mongod start

Check log
cat /var/log/mongodb.log

Stop and Restart commands
sudo service mongod stop
sudo service mongod restart

Run mongo shell to connect to a MongoDB instance on default port 27017:
mongo or mongo --port 27017

Display the database you are using
db (returns the default database 'test')

Insert one object in the collection
db.collection.insertOne({ title: "Stampler" })

Query/Select it
db.collection.find({}) or
db.collection.find({ title: "Stampler"})

That's it. The next step is to make so NodeJS can query objects in our MongoDB instance. But before we'll set up React Native and NodeJS + KoaJS.
Feel free to comment below or hit me on twitter @HeyMarkKop

Image of Stellar post

How a Hackathon Win Led to My Startup Getting Funded

In this episode, you'll see:

  • The hackathon wins that sparked the journey.
  • The moment José and Joseph decided to go all-in.
  • Building a working prototype on Stellar.
  • Using the PassKeys feature of Soroban.
  • Getting funded via the Stellar Community Fund.

Watch the video

Top comments (1)

Collapse
 
arojunior profile image
Junior Oliveira

Hey Mark, I really advise you to use Docker for local databases. It's not usual to have databases installed locally in development machines.

Good luck!

Jetbrains image

Build Secure, Ship Fast

Discover best practices to secure CI/CD without slowing down your pipeline.

Read more

👋 Kindness is contagious

Value this insightful article and join the thriving DEV Community. Developers of every skill level are encouraged to contribute and expand our collective knowledge.

A simple “thank you” can uplift someone’s spirits. Leave your appreciation in the comments!

On DEV, exchanging expertise lightens our path and reinforces our bonds. Enjoyed the read? A quick note of thanks to the author means a lot.

Okay