-
Notifications
You must be signed in to change notification settings - Fork 3
/
customer.js
98 lines (90 loc) · 1.82 KB
/
customer.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
var Model = require('../../../index.js');
var Phone = require('./phone.js');
var Address = require('./address.js');
var Customer;
module.exports = Customer = (function () {
function Customer(args, options) {
Model.instantiate(this, args, options);
}
Customer.STATUS = {
LEAD: 0,
CUSTOMER: 1
};
var schema = {
"messages": {
"integer": "Integer error message",
"float": "Float error message",
},
"properties": {
"id" : {
"type": "integer",
"primaryKey": true,
"autoIncrement": true
},
"name" : {
"type": "string",
"minimum": 3,
"maximum": 30
},
"email" : {
"type": "email",
"required": true,
"unique": true,
"minimum": 7,
"messages": {
"type": "is not a valid email!!",
"minimum": "Short email (custom attribute message)"
}
},
"age" : {
"type": "integer"
},
"hands" : {
"type": "integer"
},
"income" : {
"type": "float"
},
"birthDate" : {
"type": "date"
},
"createdAt" : {
"type": "datetime"
},
"tags" : {
"type": "array"
},
"active" : {
"type": "boolean"
},
"gender": {
"type": "enum",
"values" : {
"ref": ["M", "F"],
"type": "char"
}
},
"phones" :{
"type": "array",
"model": {
"ref": Phone
}
},
"address": {
"type": "object",
"model": {
"ref": Address
}
},
"statusId" : {
"type": "enum",
"values": {
"ref": Customer.STATUS,
"type": "integer"
}
}
}
};
Model.init(Customer, schema);
return Customer;
})();