-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmongo.js
45 lines (37 loc) · 959 Bytes
/
mongo.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
41
42
43
44
45
// 몽고디비 연결 보안주의
const mongoose = require("mongoose");
mongoose.connect("mongodb://IP/DATABASE", { useNewUrlParser: true, useUnifiedTopology: true });
const mongo = mongoose.connection;
mongo.on("error", function () {
console.log("Connection Failed!");
});
mongo.once("open", function () {
console.log("Connected!");
});
// 충전소
const charge = mongoose.Schema({
addr: String,
id: String,
name: String,
lat: String,
longi: String,
count: Number,
});
//리뷰
const review = mongoose.Schema({
mem_id: String,
date: Date,
star: Number,
csId: Number,
content: String,
});
//북마크
const bookmark = mongoose.Schema({
mem_id: String,
csId: String,
date: Date,
});
// 모델 모듈화
module.exports.charge = mongoose.model("ev_info", charge, "ev_info");
module.exports.review = mongoose.model("review", review, "review");
module.exports.bookmark = mongoose.model("bookmark", bookmark, "bookmark");