0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-07 05:32:41 +00:00

Initial Commit. All seems to be working...?

EditPage.jsx and GoogleActions.js need to be cleaned up and shortened...
This commit is contained in:
Trevor Buckner
2020-10-05 23:33:15 -04:00
parent 2065ff80ff
commit 35e1ce0df2
19 changed files with 1148 additions and 108 deletions

View File

@@ -1,11 +1,11 @@
const mongoose = require('mongoose');
const shortid = require('shortid');
const { nanoid } = require('nanoid');
const _ = require('lodash');
const zlib = require('zlib');
const HomebrewSchema = mongoose.Schema({
shareId : { type: String, default: shortid.generate, index: { unique: true } },
editId : { type: String, default: shortid.generate, index: { unique: true } },
shareId : { type: String, default: nanoid(12), index: { unique: true } },
editId : { type: String, default: nanoid(12), index: { unique: true } },
title : { type: String, default: '' },
text : { type: String, default: '' },
textBin : { type: Buffer },
@@ -24,7 +24,6 @@ const HomebrewSchema = mongoose.Schema({
}, { versionKey: false });
HomebrewSchema.methods.sanatize = function(full=false){
const brew = this.toJSON();
delete brew._id;
@@ -35,7 +34,6 @@ HomebrewSchema.methods.sanatize = function(full=false){
return brew;
};
HomebrewSchema.methods.increaseView = function(){
return new Promise((resolve, reject)=>{
this.lastViewed = new Date();
@@ -47,8 +45,6 @@ HomebrewSchema.methods.increaseView = function(){
});
};
HomebrewSchema.statics.get = function(query){
return new Promise((resolve, reject)=>{
Homebrew.find(query, (err, brews)=>{
@@ -77,11 +73,9 @@ HomebrewSchema.statics.getByUser = function(username, allowAccess=false){
});
};
const Homebrew = mongoose.model('Homebrew', HomebrewSchema);
module.exports = {
schema : HomebrewSchema,
model : Homebrew,
};
};