Skip to content

Commit 57c5629

Browse files
committed
Mongoose Part 2
1 parent 9826b31 commit 57c5629

File tree

1 file changed

+44
-20
lines changed
  • Server-side Development with NodeJS, Express and MongoDB/node-mongoose

1 file changed

+44
-20
lines changed

Server-side Development with NodeJS, Express and MongoDB/node-mongoose/index.js

Lines changed: 44 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,51 @@ connect.then((db) => {
99

1010
console.log('Connected correctly to server');
1111

12-
var newDish = Dishes({
13-
name: 'Uthappizza',
14-
description: 'test'
12+
// var newDish = Dishes({
13+
// name: 'Uthappizza',
14+
// description: 'test'
15+
// });
16+
17+
// newDish.save()
18+
// .then((dish) => {
19+
// console.log(dish);
20+
21+
// return Dishes.find({});
22+
// })
23+
// .then((dishes) => {
24+
// console.log(dishes);
25+
26+
// return Dishes.remove({});
27+
// })
28+
// .then(() => {
29+
// return mongoose.connection.close();
30+
// })
31+
// .catch((err) => {
32+
// console.log(err);
33+
// });
34+
35+
Dishes.create({
36+
name: 'Uthapizza',
37+
description: 'Test'
38+
})
39+
.then((dish) => {
40+
console.log(dish);
41+
42+
return Dishes.find({}).exec();
43+
})
44+
.then((dishes) => {
45+
console.log(dishes);
46+
47+
return Dishes.remove({});
48+
})
49+
.then(() => {
50+
return mongoose.connection.close();
51+
})
52+
.catch((err) => {
53+
console.log(err);
1554
});
55+
56+
1657

17-
newDish.save()
18-
.then((dish) => {
19-
console.log(dish);
20-
21-
return Dishes.find({});
22-
})
23-
.then((dishes) => {
24-
console.log(dishes);
25-
26-
return Dishes.remove({});
27-
})
28-
.then(() => {
29-
return mongoose.connection.close();
30-
})
31-
.catch((err) => {
32-
console.log(err);
33-
});
3458

3559
});

0 commit comments

Comments
 (0)