Fix where parsing needs to be spread
Otherwise we get a sequelize options object that looks like ```js { where: { where: {} } } ```
This commit is contained in:
parent
79c6a81a3a
commit
46d2605830
@ -79,7 +79,7 @@ export const list = ({ server, model, prefix, config }) => {
|
|||||||
if (include instanceof Error) return void reply(include);
|
if (include instanceof Error) return void reply(include);
|
||||||
|
|
||||||
const list = await model.findAll({
|
const list = await model.findAll({
|
||||||
where, include,
|
...where, include,
|
||||||
});
|
});
|
||||||
|
|
||||||
reply(list);
|
reply(list);
|
||||||
@ -101,7 +101,7 @@ export const get = ({ server, model, prefix, config }) => {
|
|||||||
const { id } = request.params;
|
const { id } = request.params;
|
||||||
if (id) where[model.primaryKeyField] = id;
|
if (id) where[model.primaryKeyField] = id;
|
||||||
|
|
||||||
const instance = await model.findOne({ where, include });
|
const instance = await model.findOne({ ...where, include });
|
||||||
|
|
||||||
if (!instance) return void reply(notFound(`${id} not found.`));
|
if (!instance) return void reply(notFound(`${id} not found.`));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user