mirror of
https://github.com/strapi/strapi.git
synced 2025-10-14 09:34:32 +00:00
Merge pull request #3612 from strapi/feature/group-cm-mongoose
CRUD Group mongoose
This commit is contained in:
commit
b49e5a56fc
@ -17,6 +17,7 @@ module.exports = ({ models, target, plugin = false }, ctx) => {
|
|||||||
definition.associations = [];
|
definition.associations = [];
|
||||||
definition.globalName = _.upperFirst(_.camelCase(definition.globalId));
|
definition.globalName = _.upperFirst(_.camelCase(definition.globalId));
|
||||||
definition.loadedModel = {};
|
definition.loadedModel = {};
|
||||||
|
definition.ObjectId = mongoose.Types.ObjectId;
|
||||||
// Set the default values to model settings.
|
// Set the default values to model settings.
|
||||||
_.defaults(definition, {
|
_.defaults(definition, {
|
||||||
primaryKey: '_id',
|
primaryKey: '_id',
|
||||||
|
@ -8,18 +8,17 @@ module.exports = ({ model, modelKey }) => {
|
|||||||
});
|
});
|
||||||
const excludedKeys = assocKeys.concat(groupKeys);
|
const excludedKeys = assocKeys.concat(groupKeys);
|
||||||
|
|
||||||
function excludeExernalValues(values) {
|
const defaultPopulate = model.associations
|
||||||
return _.omit(values, excludedKeys);
|
.filter(ast => ast.autoPopulate !== false)
|
||||||
}
|
.map(ast => ast.alias);
|
||||||
|
|
||||||
|
const pickRelations = values => {
|
||||||
|
return _.pick(values, assocKeys);
|
||||||
|
};
|
||||||
|
const omitExernalValues = values => {
|
||||||
|
return _.omit(values, excludedKeys);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param {Object} entry - the entity the groups are linked ot
|
|
||||||
* @param {Object} values - Input values
|
|
||||||
* @param {Object} options
|
|
||||||
* @param {Object} options.model - the ref model
|
|
||||||
* @param {Object} options.transacting - transaction option
|
|
||||||
*/
|
|
||||||
async function createGroups(entry, values, { transacting }) {
|
async function createGroups(entry, values, { transacting }) {
|
||||||
if (groupKeys.length === 0) return;
|
if (groupKeys.length === 0) return;
|
||||||
|
|
||||||
@ -91,7 +90,7 @@ module.exports = ({ model, modelKey }) => {
|
|||||||
|
|
||||||
const groupValue = values[key];
|
const groupValue = values[key];
|
||||||
|
|
||||||
const updateOreateGroupAndLink = async ({ value, order }) => {
|
const updateOrCreateGroupAndLink = async ({ value, order }) => {
|
||||||
// check if value has an id then update else create
|
// check if value has an id then update else create
|
||||||
if (_.has(value, groupModel.primaryKey)) {
|
if (_.has(value, groupModel.primaryKey)) {
|
||||||
return groupModel
|
return groupModel
|
||||||
@ -115,23 +114,23 @@ module.exports = ({ model, modelKey }) => {
|
|||||||
{ transacting, patch: true, require: false }
|
{ transacting, patch: true, require: false }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
return groupModel
|
|
||||||
.forge()
|
|
||||||
.save(value, { transacting })
|
|
||||||
.then(group => {
|
|
||||||
return joinModel.forge().save(
|
|
||||||
{
|
|
||||||
[foreignKey]: entry.id,
|
|
||||||
slice_type: groupModel.collectionName,
|
|
||||||
slice_id: group.id,
|
|
||||||
field: key,
|
|
||||||
order,
|
|
||||||
},
|
|
||||||
{ transacting }
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
// create
|
||||||
|
return groupModel
|
||||||
|
.forge()
|
||||||
|
.save(value, { transacting })
|
||||||
|
.then(group => {
|
||||||
|
return joinModel.forge().save(
|
||||||
|
{
|
||||||
|
[foreignKey]: entry.id,
|
||||||
|
slice_type: groupModel.collectionName,
|
||||||
|
slice_id: group.id,
|
||||||
|
field: key,
|
||||||
|
order,
|
||||||
|
},
|
||||||
|
{ transacting }
|
||||||
|
);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
if (repeatable === true) {
|
if (repeatable === true) {
|
||||||
@ -146,7 +145,7 @@ module.exports = ({ model, modelKey }) => {
|
|||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
groupValue.map((value, idx) => {
|
groupValue.map((value, idx) => {
|
||||||
return updateOreateGroupAndLink({ value, order: idx + 1 });
|
return updateOrCreateGroupAndLink({ value, order: idx + 1 });
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@ -159,7 +158,7 @@ module.exports = ({ model, modelKey }) => {
|
|||||||
transacting,
|
transacting,
|
||||||
});
|
});
|
||||||
|
|
||||||
await updateOreateGroupAndLink({ value: groupValue, order: 1 });
|
await updateOrCreateGroupAndLink({ value: groupValue, order: 1 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -196,7 +195,7 @@ module.exports = ({ model, modelKey }) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const idsToDelete = _.difference(allIds, idsToKeep);
|
const idsToDelete = _.difference(allIds, idsToKeep);
|
||||||
if (idsToDelete > 0) {
|
if (idsToDelete.length > 0) {
|
||||||
await joinModel
|
await joinModel
|
||||||
.forge()
|
.forge()
|
||||||
.query(qb => qb.whereIn('slice_id', idsToDelete))
|
.query(qb => qb.whereIn('slice_id', idsToDelete))
|
||||||
@ -252,11 +251,7 @@ module.exports = ({ model, modelKey }) => {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
find(params, populate) {
|
find(params, populate) {
|
||||||
const withRelated =
|
const withRelated = populate || defaultPopulate;
|
||||||
populate ||
|
|
||||||
model.associations
|
|
||||||
.filter(ast => ast.autoPopulate !== false)
|
|
||||||
.map(ast => ast.alias);
|
|
||||||
|
|
||||||
const filters = convertRestQueryParams(params);
|
const filters = convertRestQueryParams(params);
|
||||||
|
|
||||||
@ -266,11 +261,7 @@ module.exports = ({ model, modelKey }) => {
|
|||||||
},
|
},
|
||||||
|
|
||||||
findOne(params, populate) {
|
findOne(params, populate) {
|
||||||
const withRelated =
|
const withRelated = populate || defaultPopulate;
|
||||||
populate ||
|
|
||||||
model.associations
|
|
||||||
.filter(ast => ast.autoPopulate !== false)
|
|
||||||
.map(ast => ast.alias);
|
|
||||||
|
|
||||||
return model
|
return model
|
||||||
.forge({
|
.forge({
|
||||||
@ -288,12 +279,8 @@ module.exports = ({ model, modelKey }) => {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async create(values) {
|
async create(values) {
|
||||||
const relations = _.pick(
|
const relations = pickRelations(values);
|
||||||
values,
|
const data = omitExernalValues(values);
|
||||||
model.associations.map(ast => ast.alias)
|
|
||||||
);
|
|
||||||
|
|
||||||
const data = excludeExernalValues(values);
|
|
||||||
|
|
||||||
const runCreate = async trx => {
|
const runCreate = async trx => {
|
||||||
// Create entry with no-relational data.
|
// Create entry with no-relational data.
|
||||||
@ -318,12 +305,8 @@ module.exports = ({ model, modelKey }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Extract values related to relational data.
|
// Extract values related to relational data.
|
||||||
const relations = _.pick(
|
const relations = pickRelations(values);
|
||||||
values,
|
const data = omitExernalValues(values);
|
||||||
model.associations.map(ast => ast.alias)
|
|
||||||
);
|
|
||||||
|
|
||||||
const data = excludeExernalValues(values);
|
|
||||||
|
|
||||||
const runUpdate = async trx => {
|
const runUpdate = async trx => {
|
||||||
const entry = await model
|
const entry = await model
|
||||||
@ -386,11 +369,7 @@ module.exports = ({ model, modelKey }) => {
|
|||||||
const filters = strapi.utils.models.convertParams(modelKey, params);
|
const filters = strapi.utils.models.convertParams(modelKey, params);
|
||||||
|
|
||||||
// Select field to populate.
|
// Select field to populate.
|
||||||
const withRelated =
|
const withRelated = populate || defaultPopulate;
|
||||||
populate ||
|
|
||||||
model.associations
|
|
||||||
.filter(ast => ast.autoPopulate !== false)
|
|
||||||
.map(ast => ast.alias);
|
|
||||||
|
|
||||||
return model
|
return model
|
||||||
.query(qb => {
|
.query(qb => {
|
||||||
|
@ -2,12 +2,178 @@ const _ = require('lodash');
|
|||||||
const { convertRestQueryParams, buildQuery } = require('strapi-utils');
|
const { convertRestQueryParams, buildQuery } = require('strapi-utils');
|
||||||
|
|
||||||
module.exports = ({ model, modelKey, strapi }) => {
|
module.exports = ({ model, modelKey, strapi }) => {
|
||||||
const assocs = model.associations.map(ast => ast.alias);
|
const hasPK = obj => _.has(obj, model.primaryKey) || _.has(obj, 'id');
|
||||||
|
const getPK = obj =>
|
||||||
|
_.has(obj, model.primaryKey) ? obj[model.primaryKey] : obj.id;
|
||||||
|
|
||||||
|
const assocKeys = model.associations.map(ast => ast.alias);
|
||||||
|
const groupKeys = Object.keys(model.attributes).filter(key => {
|
||||||
|
return model.attributes[key].type === 'group';
|
||||||
|
});
|
||||||
|
const excludedKeys = assocKeys.concat(groupKeys);
|
||||||
|
|
||||||
const defaultPopulate = model.associations
|
const defaultPopulate = model.associations
|
||||||
.filter(ast => ast.autoPopulate !== false)
|
.filter(ast => ast.autoPopulate !== false)
|
||||||
.map(ast => ast.alias);
|
.map(ast => ast.alias);
|
||||||
|
|
||||||
|
const pickRelations = values => {
|
||||||
|
return _.pick(values, assocKeys);
|
||||||
|
};
|
||||||
|
|
||||||
|
const omitExernalValues = values => {
|
||||||
|
return _.omit(values, excludedKeys);
|
||||||
|
};
|
||||||
|
|
||||||
|
async function createGroups(entry, values) {
|
||||||
|
if (groupKeys.length === 0) return;
|
||||||
|
|
||||||
|
for (let key of groupKeys) {
|
||||||
|
const attr = model.attributes[key];
|
||||||
|
const { group, required = true, repeatable = true } = attr;
|
||||||
|
|
||||||
|
const groupModel = strapi.groups[group];
|
||||||
|
|
||||||
|
if (required === true && !_.has(values, key)) {
|
||||||
|
const err = new Error(`Group ${key} is required`);
|
||||||
|
err.status = 400;
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_.has(values, key)) continue;
|
||||||
|
|
||||||
|
const groupValue = values[key];
|
||||||
|
|
||||||
|
if (repeatable === true) {
|
||||||
|
validateRepeatableInput(groupValue, { key, ...attr });
|
||||||
|
const groups = await Promise.all(
|
||||||
|
groupValue.map(value => groupModel.create(value))
|
||||||
|
);
|
||||||
|
|
||||||
|
const groupsArr = groups.map(group => ({
|
||||||
|
kind: groupModel.globalId,
|
||||||
|
ref: group,
|
||||||
|
}));
|
||||||
|
|
||||||
|
entry[key] = groupsArr;
|
||||||
|
await entry.save();
|
||||||
|
} else {
|
||||||
|
validateNonRepeatableInput(groupValue, { key, ...attr });
|
||||||
|
const group = await groupModel.create(groupValue);
|
||||||
|
entry[key] = [
|
||||||
|
{
|
||||||
|
kind: groupModel.globalId,
|
||||||
|
ref: group,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
await entry.save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function updateGroups(entry, values) {
|
||||||
|
if (groupKeys.length === 0) return;
|
||||||
|
|
||||||
|
for (let key of groupKeys) {
|
||||||
|
// if key isn't present then don't change the current group data
|
||||||
|
if (!_.has(values, key)) continue;
|
||||||
|
|
||||||
|
const attr = model.attributes[key];
|
||||||
|
const { group, repeatable = true } = attr;
|
||||||
|
|
||||||
|
const groupModel = strapi.groups[group];
|
||||||
|
const groupValue = values[key];
|
||||||
|
|
||||||
|
const updateOCreateGroup = async value => {
|
||||||
|
// check if value has an id then update else create
|
||||||
|
if (hasPK(value)) {
|
||||||
|
return groupModel.findOneAndUpdate(
|
||||||
|
{
|
||||||
|
[model.primaryKey]: getPK(value),
|
||||||
|
},
|
||||||
|
value,
|
||||||
|
{ new: true }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return groupModel.create(value);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (repeatable === true) {
|
||||||
|
validateRepeatableInput(groupValue, { key, ...attr });
|
||||||
|
|
||||||
|
await deleteOldGroups(entry, groupValue, { key, groupModel });
|
||||||
|
|
||||||
|
const groups = await Promise.all(groupValue.map(updateOCreateGroup));
|
||||||
|
const groupsArr = groups.map(group => ({
|
||||||
|
kind: groupModel.globalId,
|
||||||
|
ref: group,
|
||||||
|
}));
|
||||||
|
|
||||||
|
entry[key] = groupsArr;
|
||||||
|
await entry.save();
|
||||||
|
} else {
|
||||||
|
validateNonRepeatableInput(groupValue, { key, ...attr });
|
||||||
|
|
||||||
|
await deleteOldGroups(entry, groupValue, { key, groupModel });
|
||||||
|
|
||||||
|
const group = await updateOCreateGroup(groupValue);
|
||||||
|
entry[key] = [
|
||||||
|
{
|
||||||
|
kind: groupModel.globalId,
|
||||||
|
ref: group,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
await entry.save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function deleteOldGroups(entry, groupValue, { key, groupModel }) {
|
||||||
|
const groupArr = Array.isArray(groupValue) ? groupValue : [groupValue];
|
||||||
|
|
||||||
|
const idsToKeep = groupArr.filter(hasPK).map(getPK);
|
||||||
|
const allIds = await (entry[key] || [])
|
||||||
|
.filter(el => el.ref)
|
||||||
|
.map(el => el.ref._id);
|
||||||
|
|
||||||
|
// verify the provided ids are realted to this entity.
|
||||||
|
idsToKeep.forEach(id => {
|
||||||
|
if (allIds.findIndex(currentId => currentId.toString() === id) === -1) {
|
||||||
|
const err = new Error(
|
||||||
|
`Some of the provided groups in ${key} are not related to the entity`
|
||||||
|
);
|
||||||
|
err.status = 400;
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const idsToDelete = allIds.reduce((acc, id) => {
|
||||||
|
if (idsToKeep.includes(id.toString())) return acc;
|
||||||
|
return acc.concat(id);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
if (idsToDelete.length > 0) {
|
||||||
|
await groupModel.deleteMany({ [model.primaryKey]: { $in: idsToDelete } });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function deleteGroups(entry) {
|
||||||
|
if (groupKeys.length === 0) return;
|
||||||
|
|
||||||
|
for (let key of groupKeys) {
|
||||||
|
const attr = model.attributes[key];
|
||||||
|
const { group } = attr;
|
||||||
|
const groupModel = strapi.groups[group];
|
||||||
|
|
||||||
|
if (Array.isArray(entry[key]) && entry[key].length > 0) {
|
||||||
|
await groupModel.deleteMany({
|
||||||
|
[model.primaryKey]: { $in: entry[key].map(el => el.ref) },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// public api
|
||||||
return {
|
return {
|
||||||
find(params, populate) {
|
find(params, populate) {
|
||||||
const populateOpt = populate || defaultPopulate;
|
const populateOpt = populate || defaultPopulate;
|
||||||
@ -25,9 +191,7 @@ module.exports = ({ model, modelKey, strapi }) => {
|
|||||||
const populateOpt = populate || defaultPopulate;
|
const populateOpt = populate || defaultPopulate;
|
||||||
|
|
||||||
return model
|
return model
|
||||||
.findOne({
|
.findOne({ [model.primaryKey]: getPK(params) })
|
||||||
[model.primaryKey]: params[model.primaryKey] || params.id,
|
|
||||||
})
|
|
||||||
.populate(populateOpt);
|
.populate(populateOpt);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -42,23 +206,37 @@ module.exports = ({ model, modelKey, strapi }) => {
|
|||||||
|
|
||||||
async create(values) {
|
async create(values) {
|
||||||
// Extract values related to relational data.
|
// Extract values related to relational data.
|
||||||
const relations = _.pick(values, assocs);
|
const relations = pickRelations(values);
|
||||||
const data = _.omit(values, assocs);
|
const data = omitExernalValues(values);
|
||||||
|
|
||||||
// Create entry with no-relational data.
|
// Create entry with no-relational data.
|
||||||
const entry = await model.create(data);
|
const entry = await model.create(data);
|
||||||
|
|
||||||
|
await createGroups(entry, values);
|
||||||
|
|
||||||
// Create relational data and return the entry.
|
// Create relational data and return the entry.
|
||||||
return model.updateRelations({ _id: entry.id, values: relations });
|
return model.updateRelations({
|
||||||
|
[model.primaryKey]: getPK(entry),
|
||||||
|
values: relations,
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
async update(params, values) {
|
async update(params, values) {
|
||||||
|
const entry = await model.findOne({ [model.primaryKey]: getPK(params) });
|
||||||
|
|
||||||
|
if (!entry) {
|
||||||
|
const err = new Error('entry.notFound');
|
||||||
|
err.status = 404;
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
|
||||||
// Extract values related to relational data.
|
// Extract values related to relational data.
|
||||||
const relations = _.pick(values, assocs);
|
const relations = pickRelations(values);
|
||||||
const data = _.omit(values, assocs);
|
const data = omitExernalValues(values);
|
||||||
|
|
||||||
// Update entry with no-relational data.
|
// Update entry with no-relational data.
|
||||||
await model.updateOne(params, data, { multi: true });
|
await entry.updateOne(data);
|
||||||
|
await updateGroups(entry, values);
|
||||||
|
|
||||||
// Update relational data and return the entry.
|
// Update relational data and return the entry.
|
||||||
return model.updateRelations(
|
return model.updateRelations(
|
||||||
@ -67,43 +245,51 @@ module.exports = ({ model, modelKey, strapi }) => {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async delete(params) {
|
async delete(params) {
|
||||||
const data = await model
|
const entry = await model
|
||||||
.findOneAndRemove(params, {})
|
.findOneAndRemove({ [model.primaryKey]: getPK(params) })
|
||||||
.populate(defaultPopulate);
|
.populate(defaultPopulate);
|
||||||
|
|
||||||
if (!data) {
|
if (!entry) {
|
||||||
return data;
|
const err = new Error('entry.notFound');
|
||||||
|
err.status = 404;
|
||||||
|
throw err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await deleteGroups(entry);
|
||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
model.associations.map(async association => {
|
model.associations.map(async association => {
|
||||||
if (!association.via || !data._id || association.dominant) {
|
if (
|
||||||
|
!association.via ||
|
||||||
|
!entry[model.primaryKey] ||
|
||||||
|
association.dominant
|
||||||
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const search =
|
const search =
|
||||||
_.endsWith(association.nature, 'One') ||
|
_.endsWith(association.nature, 'One') ||
|
||||||
association.nature === 'oneToMany'
|
association.nature === 'oneToMany'
|
||||||
? { [association.via]: data._id }
|
? { [association.via]: entry[model.primaryKey] }
|
||||||
: { [association.via]: { $in: [data._id] } };
|
: { [association.via]: { $in: [entry[model.primaryKey]] } };
|
||||||
const update =
|
const update =
|
||||||
_.endsWith(association.nature, 'One') ||
|
_.endsWith(association.nature, 'One') ||
|
||||||
association.nature === 'oneToMany'
|
association.nature === 'oneToMany'
|
||||||
? { [association.via]: null }
|
? { [association.via]: null }
|
||||||
: { $pull: { [association.via]: data._id } };
|
: { $pull: { [association.via]: entry[model.primaryKey] } };
|
||||||
|
|
||||||
// Retrieve model.
|
// Retrieve model.
|
||||||
const model = association.plugin
|
const assocModel = association.plugin
|
||||||
? strapi.plugins[association.plugin].models[
|
? strapi.plugins[association.plugin].models[
|
||||||
association.model || association.collection
|
association.model || association.collection
|
||||||
]
|
]
|
||||||
: strapi.models[association.model || association.collection];
|
: strapi.models[association.model || association.collection];
|
||||||
|
|
||||||
return model.update(search, update, { multi: true });
|
return assocModel.update(search, update, { multi: true });
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
return data;
|
return entry;
|
||||||
},
|
},
|
||||||
|
|
||||||
search(params, populate) {
|
search(params, populate) {
|
||||||
@ -153,3 +339,36 @@ const buildSearchOr = (model, query) => {
|
|||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function validateRepeatableInput(value, { key, min, max }) {
|
||||||
|
if (!Array.isArray(value)) {
|
||||||
|
const err = new Error(`Group ${key} is repetable. Expected an array`);
|
||||||
|
err.status = 400;
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (min && value.length < min) {
|
||||||
|
const err = new Error(`Group ${key} must contain at least ${min} items`);
|
||||||
|
err.status = 400;
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
if (max && value.length > max) {
|
||||||
|
const err = new Error(`Group ${key} must contain at most ${max} items`);
|
||||||
|
err.status = 400;
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function validateNonRepeatableInput(value, { key, required }) {
|
||||||
|
if (typeof value !== 'object') {
|
||||||
|
const err = new Error(`Group ${key} should be an object`);
|
||||||
|
err.status = 400;
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (required === true && value === null) {
|
||||||
|
const err = new Error(`Group ${key} is required`);
|
||||||
|
err.status = 400;
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user