From 2b471034da382dbdff13f01da9eddd482ce01ed9 Mon Sep 17 00:00:00 2001 From: Matthieu Bessat Date: Sat, 3 Sep 2022 11:12:47 +0200 Subject: [PATCH] feat(Public): allow to fetch orgs by id --- src/controllers/PublicController.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/controllers/PublicController.ts b/src/controllers/PublicController.ts index abcddef..277f463 100644 --- a/src/controllers/PublicController.ts +++ b/src/controllers/PublicController.ts @@ -91,7 +91,14 @@ export default class PublicController { } } - Organization.find({ slugs: { '$in': slug } }).then(data => { + let findQuery: any = { slugs: { '$in': slug } } + + // allow to get organization with id + if (mongoose.Types.ObjectId.isValid(slug)) { + findQuery = { '_id': slug } + } + + Organization.find(findQuery).then(data => { if (data.length === 0) { return ErrorController.notFoundHandler()(req, res) } else {