Skip to content

Commit fbda26a

Browse files
committed
Fix toJSON
1 parent 71a522c commit fbda26a

15 files changed

+59
-59
lines changed

models/account.model.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ const AccountSchema = new mongoose.Schema({
5555
}
5656
});
5757

58-
AccountSchema.methods.toJSON = function() {
59-
const as = this.toObject();
58+
AccountSchema.methods.toJSON = function(options) {
59+
const as = this.toObject(options);
6060
delete as.__v;
6161
as.id = as._id;
6262
delete as._id;

models/accountConfirmationToken.model.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ const AccountConfirmationSchema = new mongoose.Schema({
2626
}
2727
});
2828

29-
AccountConfirmationSchema.methods.toJSON = function() {
30-
const resetObj = this.toObject();
31-
delete resetObj.__v;
32-
resetObj.id = resetObj._id;
33-
delete resetObj._id;
34-
return resetObj;
29+
AccountConfirmationSchema.methods.toJSON = function(options) {
30+
const acs = this.toObject(options);
31+
delete acs.__v;
32+
acs.id = acs._id;
33+
delete acs._id;
34+
return acs;
3535
};
3636

3737
module.exports = mongoose.model(

models/bus.model.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ const BusSchema = new mongoose.Schema({
4141
}
4242
});
4343

44-
BusSchema.methods.toJSON = function() {
45-
const bs = this.toObject();
44+
BusSchema.methods.toJSON = function(options) {
45+
const bs = this.toObject(options);
4646
delete bs.__v;
4747
bs.id = bs._id;
4848
delete bs._id;

models/emailTemplate.model.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ const EmailTemplateSchema = new mongoose.Schema({
1313
}
1414
});
1515

16-
EmailTemplateSchema.methods.toJSON = function () {
17-
const emailTemplateObj = this.toObject();
18-
delete emailTemplateObj.__v;
19-
emailTemplateObj.id = emailTemplateObj._id;
20-
delete emailTemplateObj._id;
21-
return emailTemplateObj;
16+
EmailTemplateSchema.methods.toJSON = function (options) {
17+
const ets = this.toObject(options);
18+
delete ets.__v;
19+
ets.id = ets._id;
20+
delete ets._id;
21+
return ets;
2222
};
2323

2424
// export the model

models/hacker.model.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ const HackerSchema = new mongoose.Schema({
167167
}
168168
});
169169

170-
HackerSchema.methods.toJSON = function() {
171-
const hs = this.toObject();
170+
HackerSchema.methods.toJSON = function(options) {
171+
const hs = this.toObject(options);
172172
delete hs.__v;
173173
hs.id = hs._id;
174174
delete hs._id;

models/passwordResetToken.model.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ const passwordResetSchema = new mongoose.Schema({
1212
}
1313
});
1414

15-
passwordResetSchema.methods.toJSON = function() {
16-
const resetObj = this.toObject();
17-
delete resetObj.__v;
18-
resetObj.id = resetObj._id;
19-
delete resetObj._id;
20-
return resetObj;
15+
passwordResetSchema.methods.toJSON = function(options) {
16+
const prs = this.toObject(options);
17+
delete prs.__v;
18+
prs.id = prs._id;
19+
delete prs._id;
20+
return prs;
2121
};
2222

2323
module.exports = mongoose.model("PasswordResetToken", passwordResetSchema);

models/role.model.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ const RoleSchema = new mongoose.Schema({
2828
]
2929
});
3030

31-
RoleSchema.methods.toJSON = function() {
32-
const ps = this.toObject();
33-
delete ps.__v;
34-
ps.id = ps._id;
35-
delete ps._id;
36-
return ps;
31+
RoleSchema.methods.toJSON = function(options) {
32+
const rs = this.toObject(options);
33+
delete rs.__v;
34+
rs.id = rs._id;
35+
delete rs._id;
36+
return rs;
3737
};
3838
//export the model
3939
module.exports = mongoose.model("Role", RoleSchema);

models/roleBinding.model.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ const roleBinding = new mongoose.Schema({
1919
}
2020
});
2121

22-
roleBinding.methods.toJSON = function() {
23-
const ps = this.toObject();
24-
delete ps.__v;
25-
ps.id = ps._id;
26-
delete ps._id;
27-
return ps;
22+
roleBinding.methods.toJSON = function(options) {
23+
const rb = this.toObject(options);
24+
delete rb.__v;
25+
rb.id = rb._id;
26+
delete rb._id;
27+
return rb;
2828
};
2929
//export the model
3030
module.exports = mongoose.model("RoleBinding", roleBinding);

models/settings.model.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ const settings = new mongoose.Schema({
2020
}
2121
});
2222

23-
settings.methods.toJSON = function() {
24-
const ss = this.toObject();
23+
settings.methods.toJSON = function(options) {
24+
const ss = this.toObject(options);
2525
delete ss.__v;
2626
ss.id = ss._id;
2727
delete ss._id;

models/sponsor.model.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ const SponsorSchema = new mongoose.Schema({
3131
]
3232
});
3333

34-
SponsorSchema.methods.toJSON = function() {
35-
const ss = this.toObject();
34+
SponsorSchema.methods.toJSON = function(options) {
35+
const ss = this.toObject(options);
3636
delete ss.__v;
3737
ss.id = ss._id;
3838
delete ss._id;

0 commit comments

Comments
 (0)