Update: Models

This commit is contained in:
Yûki VACHOT 2021-12-01 05:52:34 +01:00
parent 70ca726122
commit 002f79851a
10 changed files with 55 additions and 71 deletions

View file

@ -0,0 +1,23 @@
module.exports = mongoose => {
let schema = mongoose.Schema({
userId: String,
title: String,
images: Array,
url: String,
interests: Array,
comment: String,
views: Array,
isVisible: Boolean,
isActive: Boolean
},
{ timestamps: true }
);
schema.method("toJSON", function() {
const { __v, _id, ...object } = this.toObject();
object.id = _id;
return object;
});
return mongoose.model("ads", schema);
};