Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phil Morales #11

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions controllers/notes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const express = require("express");
const router = express.Router();
const Models = require("../models/Note.js");

router.get("/", (req, res) => {
Models.find({}).then(notes => res.json(notes));
});

router.get("/notes", (req, res) => {
Models.find({}).then(notes => res.json(notes));
});

router.get("/notes/:id", (req, res) => {
Models.find({}).then(notes => res.json(notes));
});
11 changes: 11 additions & 0 deletions controllers/users.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const express = require("express");
const router = express.Router();
const Models = require("../models/User.js");

router.get("/", (req, res) => {
Models.find({}).then(users => res.json(users));
});

router.get("/User/:id", (req, res) => {
Models.find({}).then(users => res.json(users));
});
14 changes: 14 additions & 0 deletions db/seed.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
{
title: "the big bang",
username: "jackson",
email: "[email protected]",
body: "hello there people"
},
{
title: "the jump man",
username: "henry",
email: "[email protected]",
body: "hello jumping people"
}
];
14 changes: 14 additions & 0 deletions db/seedData.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
{
"title": "the big bang",
"username": "jackson",
"email": "[email protected]",
"body": "hello there people"
},
{
"title": "the jump man",
"username": "henry",
"email": "[email protected]",
"body": "hello jumping people"
}
]
7 changes: 7 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
const express = require('express');
const app = express();





app.listen(3000, () => console.log('app is running'))

// DO NOT REMOVE THIS LINE:
Expand Down
16 changes: 15 additions & 1 deletion models/Note.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
const mongoose = require('../db/connection')

const noteSchema = new mongoose.Schema({})
const noteSchema = new mongoose.Schema({

title: String,
body: String,

pull: [
{
ref: 'author',
type: mongoose.Schema.Types.ObjectId
}
]

})



module.exports = mongoose.model('Note', noteSchema)
16 changes: 13 additions & 3 deletions models/User.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
const mongoose = require('../db/connection')
const mongoose = require("../db/connection");

const userSchema = new mongoose.Schema({})
const userSchema = new mongoose.Schema({
username: String,
email: String,

module.exports = mongoose.model('User', userSchema)
pull2: [
{
ref: "notes",
type: mongoose.Schema.Types.ObjectId
}
]
});

module.exports = mongoose.model("User", userSchema);
Loading