chore: lint entire codebase including db packages
This commit is contained in:
@@ -46,8 +46,12 @@ export const sanitizeQueryValue = ({
|
||||
|
||||
// Cast incoming values as proper searchable types
|
||||
if (field.type === 'checkbox' && typeof val === 'string') {
|
||||
if (val.toLowerCase() === 'true') formattedValue = true
|
||||
if (val.toLowerCase() === 'false') formattedValue = false
|
||||
if (val.toLowerCase() === 'true') {
|
||||
formattedValue = true
|
||||
}
|
||||
if (val.toLowerCase() === 'false') {
|
||||
formattedValue = false
|
||||
}
|
||||
}
|
||||
|
||||
if (['all', 'in', 'not_in'].includes(operator) && typeof formattedValue === 'string') {
|
||||
@@ -95,11 +99,14 @@ export const sanitizeQueryValue = ({
|
||||
if (operator === 'in' && Array.isArray(formattedValue)) {
|
||||
formattedValue = formattedValue.reduce((formattedValues, inVal) => {
|
||||
const newValues = [inVal]
|
||||
if (mongoose.Types.ObjectId.isValid(inVal))
|
||||
if (mongoose.Types.ObjectId.isValid(inVal)) {
|
||||
newValues.push(new mongoose.Types.ObjectId(inVal))
|
||||
}
|
||||
|
||||
const parsedNumber = parseFloat(inVal)
|
||||
if (!Number.isNaN(parsedNumber)) newValues.push(parsedNumber)
|
||||
if (!Number.isNaN(parsedNumber)) {
|
||||
newValues.push(parsedNumber)
|
||||
}
|
||||
|
||||
return [...formattedValues, ...newValues]
|
||||
}, [])
|
||||
@@ -129,8 +136,12 @@ export const sanitizeQueryValue = ({
|
||||
$geometry: { type: 'Point', coordinates: [parseFloat(lng), parseFloat(lat)] },
|
||||
}
|
||||
|
||||
if (maxDistance) formattedValue.$maxDistance = parseFloat(maxDistance)
|
||||
if (minDistance) formattedValue.$minDistance = parseFloat(minDistance)
|
||||
if (maxDistance) {
|
||||
formattedValue.$maxDistance = parseFloat(maxDistance)
|
||||
}
|
||||
if (minDistance) {
|
||||
formattedValue.$minDistance = parseFloat(minDistance)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user