File tree Expand file tree Collapse file tree 1 file changed +44
-20
lines changed
Server-side Development with NodeJS, Express and MongoDB/node-mongoose Expand file tree Collapse file tree 1 file changed +44
-20
lines changed Original file line number Diff line number Diff line change @@ -9,27 +9,51 @@ connect.then((db) => {
9
9
10
10
console . log ( 'Connected correctly to server' ) ;
11
11
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 ) ;
15
54
} ) ;
55
+
56
+
16
57
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
58
35
59
} ) ;
You can’t perform that action at this time.
0 commit comments