Showing
1 changed file
with
0 additions
and
40 deletions
1 | -const mongoose = require("mongoose"); | ||
2 | - | ||
3 | -const { Schema } = mongoose; | ||
4 | - | ||
5 | -const ProfileSchema = new Schema({ | ||
6 | - username: { type: String, required: true, unique: true }, | ||
7 | - userBJID: String, | ||
8 | - solvedBJ: Object, | ||
9 | - solvedBJ_date: Object, | ||
10 | - friendList: [String], | ||
11 | - slackWebHookURL: String, | ||
12 | - goalNum: Number, | ||
13 | -}); | ||
14 | -ProfileSchema.statics.findByUsername = function (username) { | ||
15 | - return this.findOne({ username }); | ||
16 | -}; | ||
17 | -ProfileSchema.methods.getBJID = function () { | ||
18 | - return this.userBJID; | ||
19 | -}; | ||
20 | -ProfileSchema.methods.getBJdata = function () { | ||
21 | - return this.solvedBJ; | ||
22 | -}; | ||
23 | -ProfileSchema.methods.getslackURL = function () { | ||
24 | - return this.slackWebHookURL; | ||
25 | -}; | ||
26 | -ProfileSchema.methods.getgoalNum = function () { | ||
27 | - return this.goalNum; | ||
28 | -}; | ||
29 | -ProfileSchema.methods.getTodaySovled = function () { | ||
30 | - if (this.solvedBJ_date) { | ||
31 | - return this.solvedBJ_date.presentNum; | ||
32 | - } | ||
33 | -}; | ||
34 | - | ||
35 | -ProfileSchema.methods.serialize = function () { | ||
36 | - const data = this.toJSON(); | ||
37 | - return data; | ||
38 | -}; | ||
39 | -const Profile = mongoose.model("Profile", ProfileSchema); | ||
40 | -module.exports = Profile; |
-
Please register or login to post a comment