loading...

Day 9: Set up mongoDB

mtee profile image Margaret W.N ・1 min read

Alt Text
Lets ctrl + c and ctrl + v our way out of day 9. I'll set up a database for my habit tracker by recycling and adjusting this code.

const mongoose = require ('mongoose');
const db = mongoose.connect('mongodb://localhost/habittracker');
const Habit = require('./models/habitModel');

Created a habitModel.js file in models folder and created my model:

const mongoose = require('mongoose');

const {Schema} = mongoose;

const habitModel = new Schema(
  {
    done: { type: Boolean, default:false },
    title: { type: String},
    description: { type: String},
  }
);

module.exports = mongoose.model('Habit', habitModel );

It's been an easy ride all through but today is one of those days where i like my PC better when it's off.

Finally, Day 9!

Posted on by:

mtee profile

Margaret W.N

@mtee

Developer | GADs 20 scholar | Diving into backend

Discussion

markdown guide