0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-30 15:22:41 +00:00

Separate "style" and "metadata" panels

This commit is contained in:
Trevor Buckner
2021-06-05 15:58:31 -04:00
parent 1bc0964aff
commit e67fadef02
15 changed files with 340 additions and 219 deletions

View File

@@ -24,28 +24,15 @@ const HomebrewSchema = mongoose.Schema({
version : { type: Number, default: 1 }
}, { versionKey: false });
HomebrewSchema.methods.sanatize = function(full=false){
const brew = this.toJSON();
delete brew._id;
delete brew.__v;
if(full){
delete brew.editId;
}
return brew;
};
HomebrewSchema.methods.increaseView = async function(){
this.lastViewed = new Date();
this.views = this.views + 1;
const text = this.text;
this.text = undefined;
await this.save()
HomebrewSchema.statics.increaseView = async function(query) {
const brew = await Homebrew.findOne(query).exec();
brew.lastViewed = new Date();
brew.views = brew.views + 1;
await brew.save()
.catch((err)=>{
return err;
});
this.text = text;
return this;
return brew;
};
HomebrewSchema.statics.get = function(query){