-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.js
More file actions
62 lines (56 loc) · 1.15 KB
/
models.js
File metadata and controls
62 lines (56 loc) · 1.15 KB
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
// IMPORTS
const mongoose = require("mongoose");
// SCHEMA MODELS
// ~ CONGELADOS ~
const Congelado = mongoose.model(
"Congelado",
new mongoose.Schema(
{ nombre: String, precio: Number, cantidad: Number },
{
versionKey: false, // Ignore version key
}
)
);
// ~ VEHICULOS ~
const Vehiculo = mongoose.model(
"Vehiculo",
new mongoose.Schema(
{
matricula: { type: String, unique: true },
marca: String,
modelo: String,
fechaMatriculacion: { type: Date, default: Date.now },
},
{
versionKey: false, // Ignore version key
}
)
);
// ~ REPARTIDORES ~
const Repartidor = mongoose.model(
"Repartidor",
new mongoose.Schema(
{
dni: { type: String, unique: true },
nombre: String,
apellido: String,
repartiendo: Boolean,
vehiculoId: { type: mongoose.Schema.Types.ObjectId, ref: "Vehiculo" },
},
{
versionKey: false, // Ignore version key
}
)
);
// EXPORTS
module.exports = {
Congelado: Congelado,
Vehiculo: Vehiculo,
Repartidor: Repartidor,
};
// Shorter way to export:
// module.exports = {
// Congelado
// Vehiculo
// Repartidor
// }