-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmodels.js
47 lines (43 loc) · 965 Bytes
/
models.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
const mongoose = require('mongoose');
const billsSchema = mongoose.Schema({
billDate: Date,
description: String,
totalAmount: { type: Number, required: true },
users: [
{
userId: String,
fullName: String,
splitAmount: Number,
},
],
postedTime: Date,
postedBy: {
userId: String,
fullName: String,
},
paid: Boolean,
paidByUser: {
userId: String,
fullName: String,
},
paidOff: Boolean,
memo: String,
});
billsSchema.methods.apiRepr = function() {
return {
id: this._id,
billDate: this.billDate,
description: this.description,
totalAmount: this.totalAmount,
users: this.users,
postedTime: this.postedTime,
postedBy: this.postedBy,
paid: this.paid,
paidByUser: this.paidByUser,
//dueDay: this.dueDay,
paidOff: this.paidOff,
memo: this.memo,
};
};
const Bills = mongoose.model('Bills', billsSchema, 'billscollection');
module.exports = { Bills };