mirror of
https://framagit.org/les/gancio.git
synced 2025-01-31 16:42:22 +01:00
new queryParamToBool helper
This commit is contained in:
parent
892f560634
commit
d7f1dd686c
2 changed files with 5 additions and 4 deletions
|
@ -2,13 +2,13 @@ const { Collection, Filter, Event, Tag, Place } = require('../models/models')
|
|||
|
||||
const log = require('../../log')
|
||||
const { DateTime } = require('luxon')
|
||||
const { col: Col } = require('../../helpers')
|
||||
const { col: Col, queryParamToBool } = require('../../helpers')
|
||||
const { Op, Sequelize } = require('sequelize')
|
||||
|
||||
const collectionController = {
|
||||
|
||||
async getAll (req, res) {
|
||||
const withFilters = req.query.withFilters
|
||||
const withFilters = queryParamToBool(req.query.withFilters)
|
||||
let collections
|
||||
if (withFilters) {
|
||||
collections = await Collection.findAll({ include: [ Filter ] })
|
||||
|
|
|
@ -295,8 +295,9 @@ module.exports = {
|
|||
}
|
||||
},
|
||||
|
||||
queryParamToBool (value) {
|
||||
return ((value+'').toLowerCase() === 'true')
|
||||
queryParamToBool (value, defaultValue) {
|
||||
if (typeof value === 'undefined') return defaultValue
|
||||
return (String(value).toLowerCase() === 'true')
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue