-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Description
When using select on a breeze query, the result returns also the sequelize models (especially if we expand into some navigation property) and this creates serialization problems
I managed to overcome this issue by using the Model.get({ plain: true }) which returns simple javascript objects without the sequelize models and also with nested sub-objects / sub-arrays which IMHO maps better to what the client might expect
Proposed method change in SequelizeQuery.js
private _reshapeSelectResults(sqResults: CountModel | Model[]) {
const options = {
plain: true
};
if (this.entityQuery.inlineCountEnabled) {
return {
results: (sqResults as CountModel).rows.map(x => x.get(options)),
inlineCount: (sqResults as CountModel).count
};
} else {
return (sqResults as Model[]).map(x => x.get(options));
}
}
It is tested and works well but it changes the semantics because now for nested properties the system returns
{
"foo.bar": 1
}
and my code returns
{
foo: {
bar: 1
}
}
But this allows us to handle nested arrays which did not work before
Metadata
Metadata
Assignees
Labels
No labels