-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.js
More file actions
69 lines (63 loc) · 1.25 KB
/
models.js
File metadata and controls
69 lines (63 loc) · 1.25 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
'use strict';
const mongoose = require('mongoose');
const uuid = require('node-uuid');
const UserSchema = mongoose.Schema({
name: {
type: String,
required: true,
minlength: 1
},
token: {
type: String,
required: true,
minlength: 1
},
age: {
type: Number,
required: true,
min: 0
},
gender: {
type: String,
required: true,
maxlength: 1,
minlength: 1
},
});
const CompanySchema = mongoose.Schema({
name: {
type: String,
required: true,
minlength: 1
},
description: {
type: String,
required: true,
minlength: 1
},
punchcard_lifetime: {
type: Number,
required: true
}
});
const PunchcardSchema = mongoose.Schema({
company_id: {
type: String,
required: true,
minlength: 1
},
user_id: {
type: String,
required: true,
minlength: 1
},
created: {
type: Date,
default: new Date()
}
});
module.exports = {
User: mongoose.model('User', UserSchema),
Company: mongoose.model('Company', CompanySchema),
Punchcard: mongoose.model('Punchcard', PunchcardSchema)
};