Created
April 2, 2017 04:59
-
-
Save ninjasort/c0afa0fcfb940fc7862f397f784f8eb2 to your computer and use it in GitHub Desktop.
CRUD App in Node
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
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