Created
March 19, 2023 16:33
-
-
Save bryancodesjs/eea7dc232dcfbfefa760ecd0ba3406ad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mongoose = require('mongoose'); | |
const DB_PORT = 27017; | |
const DB_NAME = 'playground'; | |
mongoose.connect(`mongodb://localhost:${DB_PORT}/${DB_NAME}`) | |
.then(() => console.log('Connected to Mongo...')) | |
.catch(err => console.error('Could not connect...', err)) | |
const courseSchema = new mongoose.Schema({ | |
name: String, | |
author: String, | |
tags: [String], | |
date: { type: Date, default: Date.now}, | |
isPublished: Boolean | |
}) | |
//mongoose.model() takes two arguments, the first is the name of the model, | |
//the second is the schema | |
const Course = mongoose.model('Course', courseSchema); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment