File tree Expand file tree Collapse file tree 6 files changed +3619
-0
lines changed Expand file tree Collapse file tree 6 files changed +3619
-0
lines changed Original file line number Diff line number Diff line change
1
+ node_modules
2
+ /node_modules
Original file line number Diff line number Diff line change
1
+ const mongoose = require ( 'mongoose' )
2
+
3
+ const CotectSchema = new mongoose . Schema ( {
4
+ name :{
5
+ type :String ,
6
+ require :true
7
+ } ,
8
+ phone :{
9
+ type :String ,
10
+ require :true
11
+ }
12
+ } )
Original file line number Diff line number Diff line change
1
+ const exp = require ( 'express' ) // Exp is the name randum only
2
+ const port = 800 ;
3
+ const db = require ( './mong' ) ;
4
+ const app = exp ( ) ;
5
+
6
+ app . get ( '/' , ( req , res ) => {
7
+ // console.log(req);
8
+ res . send ( "<h1 style='color:red; background-color:yellow;text-align:center'>Hye. ! I am Express ;)</h1>" )
9
+
10
+ } )
11
+
12
+
13
+ app . listen ( port , ( err ) => {
14
+ if ( err ) {
15
+ console . log ( "Error..! :(" , err ) ;
16
+ }
17
+
18
+ console . log ( "Express : I am running at port number :" , port )
19
+
20
+ } )
Original file line number Diff line number Diff line change
1
+ //require the library
2
+ const mongoose = require ( 'mongoose' ) ;
3
+
4
+ //connect to the database
5
+ mongoose . connect ( 'mongodb://127.0.0.1/contact_list_db' ) ;
6
+
7
+ //acquire the connection(to check if it's successful)
8
+ const db = mongoose . connection ;
9
+
10
+ //error
11
+ db . on ( 'error' , function ( err ) { console . log ( err . message ) ; } ) ;
12
+
13
+ //up and running then print the message
14
+ db . once ( 'open' , function ( ) {
15
+
16
+ console . log ( "Successfully connected to the database" ) ;
17
+
18
+ } ) ;
You can’t perform that action at this time.
0 commit comments