forked from MyZubster-Ecosystem/myzubster
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPhoto.js
More file actions
70 lines (68 loc) 路 1.19 KB
/
Copy pathPhoto.js
File metadata and controls
70 lines (68 loc) 路 1.19 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
63
64
65
66
67
68
69
70
const mongoose = require('mongoose');
const photoSchema = new mongoose.Schema(
{
gardenId: {
type: mongoose.Schema.Types.ObjectId,
ref: 'Garden',
required: true,
index: true,
},
filename: {
type: String,
required: true,
trim: true,
},
originalName: {
type: String,
required: true,
},
path: {
type: String,
required: true,
},
thumbnailPath: {
type: String,
default: null,
},
mimeType: {
type: String,
required: true,
},
size: {
type: Number,
required: true,
},
width: {
type: Number,
default: null,
},
height: {
type: Number,
default: null,
},
caption: {
type: String,
trim: true,
default: '',
maxlength: 500,
},
uploadedBy: {
type: String,
trim: true,
default: 'anonymous',
},
},
{
versionKey: false,
timestamps: true,
toJSON: {
virtuals: true,
transform: (_doc, ret) => {
ret.id = ret._id.toString();
delete ret._id;
return ret;
},
},
}
);
module.exports = mongoose.model('Photo', photoSchema);