-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdb.js
63 lines (57 loc) · 980 Bytes
/
db.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
var mongoose = require("mongoose");
var uristring = process.env.MONGODB_URI || process.env.MONGOLAB_URI || 'mongodb://localhost/gapp';
var mongoOptions = {
db: {
safe: true
}
};
var db = mongoose.connect(uristring, mongoOptions, function(err, res) {
if (err) {
console.log('ERROR connecting to: ' + uristring + '. ' + err);
} else {
console.log('Succeeded connected to: ' + uristring);
}
});
var Schema = mongoose.Schema,
ObjectId = Schema.ObjectId;
var geo = new Schema({
loc: {
type: [Number],
index: '2dsphere'
}
})
var placeSchema = new Schema({
type: {
type: String,
},
where: {
type: String,
},
dateCreated: {
type: Date,
},
dateModified: {
type: Date,
},
status: {
type: Boolean,
},
habitat: {
type: Boolean,
},
foodSource: {
type: Boolean,
},
noPesticides: {
type: Boolean,
},
image: {
type: String,
},
loc: {
type: Array
},
comments: [],
support: []
})
exports.Place = mongoose.model('places', placeSchema);