mirror of
https://github.com/strapi/strapi.git
synced 2025-07-21 07:57:45 +00:00
parent
aab2f3e06c
commit
6143c3e1ca
18
packages/strapi-utils/lib/models.js
Executable file → Normal file
18
packages/strapi-utils/lib/models.js
Executable file → Normal file
@ -457,11 +457,25 @@ module.exports = {
|
|||||||
_.forEach(params, (value, key) => {
|
_.forEach(params, (value, key) => {
|
||||||
let result;
|
let result;
|
||||||
let formattedValue;
|
let formattedValue;
|
||||||
|
let modelAttributes = models[model]['attributes'];
|
||||||
// Check if the value if a valid candidate to be converted to a number value
|
let fieldType;
|
||||||
|
// Get the field type to later check if it's a string before number conversion
|
||||||
|
if (modelAttributes[key]) {
|
||||||
|
fieldType = modelAttributes[key]['type'];
|
||||||
|
} else {
|
||||||
|
let splitKey = key.split('_').pop();
|
||||||
|
if (modelAttributes[splitKey]) {
|
||||||
|
fieldType = modelAttributes[splitKey]['type'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Check if the value is a valid candidate to be converted to a number value
|
||||||
|
if (fieldType != 'string') {
|
||||||
formattedValue = isNumeric(value)
|
formattedValue = isNumeric(value)
|
||||||
? _.toNumber(value)
|
? _.toNumber(value)
|
||||||
: value;
|
: value;
|
||||||
|
} else {
|
||||||
|
formattedValue = value;
|
||||||
|
}
|
||||||
|
|
||||||
if (_.includes(['_start', '_limit'], key)) {
|
if (_.includes(['_start', '_limit'], key)) {
|
||||||
result = convertor(formattedValue, key);
|
result = convertor(formattedValue, key);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user