Tag: MongoDB

Introduction to MongoDB

Status: draft Adding Unique Index Lets say you have a database called my_db and you have a collection in my_db called users which has typical user related fields like first_name, last_name, email, user_id, etc. Now, you want to set unique index on user_id and email field separately. We can do it from terminal using mongoDB […]

Connect to MongoDB from Flask-PyMongo

Get started with dockerized MongoDB Get the MongoDB image from here: https://hub.docker.com/_/mongo. Setup the MongoDB container using docker-compose (docker-compose.yaml): version: ‘3.1’ services: mongo: image: mongo:4.0.8-xenial restart: always network_mode: bridge container_name: mongo environment: MONGO_INITDB_DATABASE: admin MONGO_INITDB_ROOT_USERNAME: root MONGO_INITDB_ROOT_PASSWORD: root ports: – 27017:27017 volumes: – ./mongodbdata:/data/db – ./initdb:/docker-entrypoint-initdb.d mongo-express: image: mongo-express restart: always ports: – 8081:8081 network_mode: […]

Back To Top