Skip to content

Commit 115def8

Browse files
committed
tweaks
1 parent d02965b commit 115def8

File tree

3 files changed

+33
-27
lines changed

3 files changed

+33
-27
lines changed

app/models/user.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
var mongoose = require('mongoose'),
2+
Schema = mongoose.Schema;
3+
4+
// Validation helper methods should return booleans
5+
// and should be defined before the schema for readability
6+
7+
8+
// Model Schema
9+
//var ModelSchema = new Schema ({
10+
// name : {
11+
// type: String
12+
// },
13+
//});+
14+
15+
// Model Schema
16+
var ModelSchema = new Schema ({
17+
firstname : {
18+
type: String
19+
},
20+
lastname : {
21+
type: String
22+
},
23+
email : {
24+
type: String
25+
},
26+
password : {
27+
type: String
28+
}
29+
});
30+
module.exports = mongoose.model('User', ModelSchema);

app/routes/api.js

+2-26
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Module for API Routes (serving JSON)
22
module.exports = function(app) {
33
var mongoose = require('mongoose'),
4-
Model = require('../models/model')
4+
Model = require('../models/user')
55

66
// Example API route
77
app.get('/models', function(req, res) {
@@ -44,7 +44,7 @@ module.exports = function(app) {
4444
});
4545
});
4646
// Example POST route
47-
app.get('/login', function (req, res) {
47+
app.get('/users', function (req, res) {
4848
var isExists = con.find({
4949
email : req.body.email // Bound using Angular
5050
});
@@ -74,28 +74,4 @@ module.exports = function(app) {
7474
});
7575
});
7676
});
77-
// Example POST route
78-
app.post('/users', function (req, res) {
79-
Model.create({
80-
email : req.body.email, // Bound using Angular
81-
password : req.body.password
82-
}, function(err, model) {
83-
if(err) {
84-
res.send("Please try again!");
85-
}
86-
87-
Model.find(function(err, users) {
88-
res.send("You are Registered!");
89-
});
90-
});
91-
});
92-
app.get('/users', function(req, res) {
93-
94-
// Checks the model collection and returns all of them`
95-
Model.find(function(err, users) {
96-
97-
// returns all people in JSON format
98-
res.send(users);
99-
});
100-
});
10177
}

config/db.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module.exports = {
2-
url : 'mongodb://localhost:27017/users'
2+
url : 'mongodb://localhost:27017/angular-notes'
33
}

0 commit comments

Comments
 (0)