Migration to v6 - Associated tables attributes are no longer defined in Smart Fields getters

Expected behavior

We have Smart Fields that use attributes from associated tables in their “get” function.
Before upgrading to v6 (node), all attributes were accessible.

Actual behavior

Now it seems only the field used for reference for display is defined.
i.e. on the “users” list view, we have a field that returns ${user.address.street}, ${user.address.city}.
‘city’ is still defined, i guess it’s because it’s the field selected as “Reference field”, but all other fields from “user.address” are not defined anymore.
We have multiple fields like this so adding an extra db request would have a big performance impact.
Is there something we can do to make those fields directly accessible ?

Thanks in advance,


  • Package Version: forest-express-sequelize: 6.6.3
  • Project Name: ma-domiciliation

Hi @kmcb :wave: yeah we have removed unused field from the request for performance issue.
To bypass this you can add a beforeFind hook inside your Sequelize user model like this:

hooks: {
  beforeFind: (options) => {
    // the code below select for all included models all the attributes
    // you can probably do something more efficient
    options.include.forEach(model => {
      delete model.attributes;

Le me know if that help.

Hi Arnaud,
Thank you very much, i don’t have time to test today but this should work indeed.

1 Like

It worked, however i had to check if options.include is defined, this hook is called with undefined include when updating a user on the ui.
I ended up with something like this :

          if (options.include) {
            options.include.forEach(model => {
              if (model.as === 'contract') {
                model.attributes = [ 'id', ...otherAttributes ]