Feature(s) impacted
Smart Relationship
Observed behavior
I just created a Smart Collection “lcbft-scores” and I’m trying to set up a Smart Relationship with a “normal” collection, the “users” db table.
The column of the relation remains empty.
Here is the code of the field declaration :
{
field: 'user',
type: 'String',
reference: 'User',
get: (line) => {
if (!line.id) return null
return db.User.findByPk(line.id)
},
}
The “line.id” is correctly filled with the user id.
I don’t know if i need to fill a “user” attribute in the code of the route that returns the values for the smart collection, in the “user” field I tried to pass the id, the whole user object, and null, but the “user” column is still empty in the displayed table.
I noticed by adding logs that the “get” function of the declaration is never called.
(If you test on our environment, it’s normal if the smart collection returns an empty line, you need to enter a user id in the search field so that it returns the line for this user. You can use the id “3381” to get values).
Also, i wonder if it’s possible to add a link to the smart collection in the “users” summary view, like for any 1:1 relationship. On the fields config page, the “user” appears in the list of the relationships of the smart collection, but the “lcbft-scores” smart collection doesn’t appear in the list of the user relationships. I didn’t try to declare the relationship in the “user” model, i don’t think it would work since “lcbft-scores” is not an actual db model.
Is there a way to do this ?
Thanks in advance
Context
- Project name: ma-domiciliation
- Team name: Admin et dev
- Environment name: Staging-dev
- Agent technology: node
- Agent (forest package) name & version: “forest-express-sequelize”: “~9.3.10”,
- Database type: postgres