feat(Public): allow to fetch orgs by id

This commit is contained in:
Matthieu Bessat 2022-09-03 11:12:47 +02:00
parent 844244b90a
commit 2b471034da

View file

@ -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) { if (data.length === 0) {
return ErrorController.notFoundHandler()(req, res) return ErrorController.notFoundHandler()(req, res)
} else { } else {