0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-26 13:52:38 +00:00

Merge pull request #2737 from naturalcrit/dependabot/npm_and_yarn/mongoose-7.0.2

Bump mongoose from 6.9.2 to 7.0.2
This commit is contained in:
Trevor Buckner
2023-03-21 16:14:03 -04:00
committed by GitHub
5 changed files with 15730 additions and 29741 deletions

View File

@@ -255,9 +255,10 @@ const MetadataEditor = createClass({
default={this.props.metadata.lang || ''}
placeholder='en'
onSelect={(value)=>this.handleLanguage(value)}
onEntry={(e)=> { e.target.setCustomValidity(''); //Clear the validation popup while typing
debouncedHandleFieldChange('lang', e);
}}
onEntry={(e)=>{
e.target.setCustomValidity(''); //Clear the validation popup while typing
debouncedHandleFieldChange('lang', e);
}}
options={listLanguages()}
autoSuggest={{
suggestMethod : 'startsWith',

45420
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -94,7 +94,7 @@
"marked-extended-tables": "^1.0.5",
"markedLegacy": "npm:marked@^0.3.19",
"moment": "^2.29.4",
"mongoose": "^6.9.2",
"mongoose": "^7.0.2",
"nanoid": "3.3.4",
"nconf": "^0.12.0",
"npm": "^9.6.2",

View File

@@ -27,8 +27,8 @@ const disconnect = async ()=>{
};
const connect = async (config)=>{
return await Mongoose.connect(getMongoDBURL(config),
{ retryWrites: false }, handleConnectionError);
return await Mongoose.connect(getMongoDBURL(config), { retryWrites: false })
.catch((error)=>handleConnectionError(error));
};
module.exports = {

View File

@@ -40,30 +40,24 @@ HomebrewSchema.statics.increaseView = async function(query) {
return brew;
};
HomebrewSchema.statics.get = function(query, fields=null){
return new Promise((resolve, reject)=>{
Homebrew.find(query, fields, null, (err, brews)=>{
if(err || !brews.length) return reject('Can not find brew');
if(!_.isNil(brews[0].textBin)) { // Uncompress zipped text field
unzipped = zlib.inflateRawSync(brews[0].textBin);
brews[0].text = unzipped.toString();
}
return resolve(brews[0]);
});
});
HomebrewSchema.statics.get = async function(query, fields=null){
const brew = await Homebrew.findOne(query, fields).orFail()
.catch((error)=>{throw 'Can not find brew';});
if(!_.isNil(brew.textBin)) { // Uncompress zipped text field
unzipped = zlib.inflateRawSync(brew.textBin);
brew.text = unzipped.toString();
}
return brew;
};
HomebrewSchema.statics.getByUser = function(username, allowAccess=false, fields=null){
return new Promise((resolve, reject)=>{
const query = { authors: username, published: true };
if(allowAccess){
delete query.published;
}
Homebrew.find(query, fields).lean().exec((err, brews)=>{ //lean() converts results to JSObjects
if(err) return reject('Can not find brew');
return resolve(brews);
});
});
HomebrewSchema.statics.getByUser = async function(username, allowAccess=false, fields=null){
const query = { authors: username, published: true };
if(allowAccess){
delete query.published;
}
const brews = await Homebrew.find(query, fields).lean().exec() //lean() converts results to JSObjects
.catch((error)=>{throw 'Can not find brews';});
return brews;
};
const Homebrew = mongoose.model('Homebrew', HomebrewSchema);