-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.js
55 lines (49 loc) · 1.62 KB
/
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
var mongoose = require('mongoose');
//define schemas
var Exoplanet = new mongoose.Schema({
HostName: {type:String},
PlanetLetter: {type:String, required: true},
Discovery: {type:String},
NumPlanetsInSystem: {type:Number, required:true},
OrbitalPeriod: {type:Number, required:true},
OrbitSemiMajorAxis: {type:Number},
Eccentricity: {type:Number},
Inclination: {type:Number},
MassWRTJupiter: {type:Number},
Density: {type:Number},
TVVFlag: {type:Number},
KeplerFieldFlag : {type:Number},
K2MissionFlag: {type:Number},
NumberOfNotes: {type:Number},
RAStr: {type:String},
RA: {type:Number},
DecStr: {type:String},
Dec: {type:Number},
Distance: {type:Number, required:true},
OpticalMagnitude: {type:Number},
OpticalMagnitudeBand : {type:String},
TemperatureK : {type:Number, required:true},
StellarMass: {type:Number, required:true},
StellarRadius: {type:Number, required:true},
Updated: {type:Date},
NASA: false
});
var List = new mongoose.Schema({
user: {type: mongoose.Schema.Types.ObjectId, ref:'User'},
name: {type: String, required: true},
created: {type: Date, required: true},
planets: [Exoplanet]
});
var User = new mongoose.Schema({
name: {type:String, required:true},
fb: {type: Boolean, required: true}, //if the user signs in with facebook
username: {type:String, required:true},
password: {type:String, required:true},
lists: [{type: mongoose.Schema.Types.ObjectId, ref: 'List'}]
});
//register schema as model
mongoose.model("Exoplanet", Exoplanet);
mongoose.model("List", List);
mongoose.model("User", User);
//connect to db
mongoose.connect('mongodb://localhost/stars');