Fix small comments
parent
879e8908a0
commit
510312d347
|
@ -25,7 +25,7 @@ const ConfigType = class ConfigType {
|
||||||
this.configPrefix = configName;
|
this.configPrefix = configName;
|
||||||
this.jsonFields = jsonFields || [];
|
this.jsonFields = jsonFields || [];
|
||||||
this.relations = relations || [];
|
this.relations = relations || [];
|
||||||
this.populate = populate || [];
|
this.populate = populate || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -111,19 +111,15 @@ const ConfigType = class ConfigType {
|
||||||
// Update entity.
|
// Update entity.
|
||||||
this.relations.map(({ relationName }) => delete query[relationName]);
|
this.relations.map(({ relationName }) => delete query[relationName]);
|
||||||
|
|
||||||
let entity;
|
const entity = await queryAPI.findOne({ where: combinedUidWhereFilter });
|
||||||
switch (this.queryString) {
|
try {
|
||||||
case "strapi::core-store":
|
await strapi.entityService.update(this.queryString, entity.id, {
|
||||||
entity = await queryAPI.update({
|
data: query,
|
||||||
where: combinedUidWhereFilter,
|
});
|
||||||
data: query,
|
} catch(error) {
|
||||||
});
|
console.warn(error);
|
||||||
break;
|
console.log("Use Query Engine API instead of Entity Service API");
|
||||||
default:
|
await queryAPI.update({ where: combinedUidWhereFilter, data: query });
|
||||||
entity = await queryAPI.findOne({ where: combinedUidWhereFilter });
|
|
||||||
await strapi.entityService.update(this.queryString, entity.id, {
|
|
||||||
data: query,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete/create relations.
|
// Delete/create relations.
|
||||||
|
@ -206,7 +202,7 @@ const ConfigType = class ConfigType {
|
||||||
*/
|
*/
|
||||||
getAllFromDatabase = async () => {
|
getAllFromDatabase = async () => {
|
||||||
const AllConfig = await noLimit(strapi.query(this.queryString), {
|
const AllConfig = await noLimit(strapi.query(this.queryString), {
|
||||||
populate: this.populate || null,
|
populate: this.populate,
|
||||||
});
|
});
|
||||||
const configs = {};
|
const configs = {};
|
||||||
|
|
||||||
|
@ -236,24 +232,18 @@ const ConfigType = class ConfigType {
|
||||||
formattedConfig[relationName] = relations;
|
formattedConfig[relationName] = relations;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
this.populate
|
if (Array.isArray(this.populate)) {
|
||||||
.filter((populatedFields) => !populatedFields.includes("."))
|
this.populate
|
||||||
.map((populatedFields) => {
|
.filter((populatedFields) => !populatedFields.includes("."))
|
||||||
|
.map((populatedFields) => {
|
||||||
formattedConfig[populatedFields] = formattedConfig[
|
formattedConfig[populatedFields] = formattedConfig[
|
||||||
populatedFields
|
populatedFields
|
||||||
].map((fields) => {
|
].map((fields) => {
|
||||||
const sanitizeObjects = (fields) => {
|
sanitizeConfig(fields);
|
||||||
sanitizeConfig(fields);
|
|
||||||
Object.keys(fields).map((key, index) => {
|
|
||||||
if (fields[key] && typeof fields[key] === "object") {
|
|
||||||
sanitizeObjects(fields[key]);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
sanitizeObjects(fields);
|
|
||||||
return fields;
|
return fields;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
this.jsonFields.map((field) => formattedConfig[field] = JSON.parse(config[field]));
|
this.jsonFields.map((field) => formattedConfig[field] = JSON.parse(config[field]));
|
||||||
configs[`${this.configPrefix}.${combinedUid}`] = formattedConfig;
|
configs[`${this.configPrefix}.${combinedUid}`] = formattedConfig;
|
||||||
|
|
|
@ -47,11 +47,6 @@ const dynamicSort = (property) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const sanitizeConfig = (config, relation, relationSortFields) => {
|
const sanitizeConfig = (config, relation, relationSortFields) => {
|
||||||
delete config._id;
|
|
||||||
delete config.id;
|
|
||||||
delete config.updatedAt;
|
|
||||||
delete config.createdAt;
|
|
||||||
|
|
||||||
if (relation) {
|
if (relation) {
|
||||||
const formattedRelations = [];
|
const formattedRelations = [];
|
||||||
|
|
||||||
|
@ -74,6 +69,20 @@ const sanitizeConfig = (config, relation, relationSortFields) => {
|
||||||
config[relation] = formattedRelations;
|
config[relation] = formattedRelations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const sanitizeRecursive = (config) => {
|
||||||
|
delete config._id;
|
||||||
|
delete config.id;
|
||||||
|
delete config.updatedAt;
|
||||||
|
delete config.createdAt;
|
||||||
|
|
||||||
|
Object.keys(config).map((key, index) => {
|
||||||
|
if (config[key] && typeof config[key] === "object") {
|
||||||
|
sanitizeRecursive(config[key]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
sanitizeRecursive(config);
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue