-
Notifications
You must be signed in to change notification settings - Fork 950
/
Copy pathlaunchpads.js
76 lines (71 loc) · 1.32 KB
/
launchpads.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
64
65
66
67
68
69
70
71
72
73
74
75
76
import mongoose from 'mongoose';
import mongoosePaginate from 'mongoose-paginate-v2';
import idPlugin from 'mongoose-id';
const launchpadSchema = new mongoose.Schema({
name: {
type: String,
default: null,
},
full_name: {
type: String,
default: null,
},
status: {
type: String,
enum: ['active', 'inactive', 'unknown', 'retired', 'lost', 'under construction'],
required: true,
},
locality: {
type: String,
default: null,
},
region: {
type: String,
default: null,
},
timezone: {
type: String,
default: null,
},
latitude: {
type: Number,
default: null,
},
longitude: {
type: Number,
default: null,
},
launch_attempts: {
type: Number,
default: 0,
},
launch_successes: {
type: Number,
default: 0,
},
rockets: [{
type: mongoose.ObjectId,
ref: 'Rocket',
}],
launches: [{
type: mongoose.ObjectId,
ref: 'Launch',
}],
details: {
type: String,
default: null,
},
images: {
large: [String],
},
}, { autoCreate: true });
const index = {
name: 'text',
full_name: 'text',
details: 'text',
};
launchpadSchema.index(index);
launchpadSchema.plugin(mongoosePaginate);
launchpadSchema.plugin(idPlugin);
const Launchpad = mongoose.model('Launchpad', launchpadSchema);
export default Launchpad;