forked from r-spacex/SpaceX-API
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcores.js
61 lines (56 loc) · 1.06 KB
/
cores.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
import mongoose from 'mongoose';
import mongoosePaginate from 'mongoose-paginate-v2';
import idPlugin from 'mongoose-id';
const coreSchema = new mongoose.Schema({
serial: {
type: String,
unique: true,
required: true,
},
block: {
type: Number,
default: null,
},
status: {
type: String,
enum: ['active', 'inactive', 'unknown', 'expended', 'lost', 'retired'],
required: true,
},
reuse_count: {
type: Number,
default: 0,
},
rtls_attempts: {
type: Number,
default: 0,
},
rtls_landings: {
type: Number,
default: 0,
},
asds_attempts: {
type: Number,
default: 0,
},
asds_landings: {
type: Number,
default: 0,
},
last_update: {
type: String,
default: null,
},
launches: [{
type: mongoose.ObjectId,
ref: 'Launch',
}],
}, { autoCreate: true });
const index = {
serial: 'text',
last_update: 'text',
};
coreSchema.index(index);
coreSchema.plugin(mongoosePaginate);
coreSchema.plugin(idPlugin);
const Core = mongoose.model('Core', coreSchema);
export default Core;