-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
40 lines (30 loc) · 874 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
var mongo = require("mongodb").MongoClient;
var express = require('express');
var bodyParser = require('body-parser');
var mongoose = require("mongoose");
var Book = require("./book.model.js");
var port =3000;
let MONGO_URL = "mongodb://ankur1163:[email protected]:13946/ank1163";
var app = express();
//app.listen(3000);
mongo.connect(MONGO_URL, function (error, db) {
if (error) {
throw new Error('Database failed to connect!');
} else {
console.log('MongoDB successfully connected on port 27017.');
}
// start the server
app.listen(3000, function() {
console.log('Express server listening on port 3000');
});
});
MONGO_URL.Book.insert({
title:"refactor the dom",
author:"ty he",
category:"tech"
})
MONGO_URL.Book.insert({
title:"1",
author:"2e",
category:"3"
})