Skip to content

Turanchoks/mongoose-findoneorfail

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Mongoose findOneOrFailPlugin

Tiny mongoose plugin which adds findOneOrFail method to a model. The method throws an error if no result is found.

Use case with express

app.get('/models/:id', (req, res, next) => {
    MongooseModel
        .findOneOrFail({
            id: req.params.id
        })
        .then(model => res.send(model))
        .catch(next);
});

About

Tiny mongoose plugin which adds findOneOrFail method to a model.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published