Skip to content

Instantly share code, notes, and snippets.

@ninjasort
Created April 2, 2017 04:59
Show Gist options
  • Save ninjasort/c0afa0fcfb940fc7862f397f784f8eb2 to your computer and use it in GitHub Desktop.
Save ninjasort/c0afa0fcfb940fc7862f397f784f8eb2 to your computer and use it in GitHub Desktop.
CRUD App in Node
import express from 'express'
import bodyParser from 'body-parser'
import mongoose from 'mongoose'
const PORT = process.env.PORT || 8080
const app = express()
// Book
const Schema = mongoose.Schema
const BookSchema = new Schema({
title: String,
author: String,
category: String
})
const Book = mongoose.model('Book', BookSchema)
// db
const db = 'mongodb://localhost/book-db'
mongoose.connect(db)
// routes
app.listen(PORT, () => {
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment