forest-express-mongoose
forest-express-mongoose copied to clipboard
Smart Fields not load on custom Related Data (with smart relationships)
Hi,
I have created multiple smart fields for a model. I then created a smart relationships to display this model on related data for an other model but here, i can see the columns for the smart fields but it's empty. The data are not loaded for this custom fields.
Thanks
Hi @GautierT,
Please add a piece of code that represents you Smart Relationship getter implementation. Without it we cannot help you here.
UPDATED
router.get('/forest/users/:userId/relationships/XX', Liana.ensureAuthenticated, async (req, res, next) => {
debug('req.body : %O', req.body)
debug('req.params : %O', req.params)
debug('req.query : %O', req.query)
try {
const results = await Letters.paginate({
user: req.params.userId,
mode: 'test'
}, {
page: parseInt(req.query.page.number),
limit: parseInt(req.query.page.size),
sort: req.query.sort,
populate: [{
path: 'XX',
select: '-__v'
}, {
path: 'XX',
select: '-__v'
}, {
path: 'XX'
}]
})
console.log('results.total : ', results.total)
const serialized = await new Serializer(Liana, Letters, results.docs, {}, {
count: results.total
// Don't seem to work
}).perform()
debug('serialized : %O', serialized)
return res.send({...serialized, meta : {count : results.total}})
}
catch (ex) {
return next(ex)
}
})
Sometimes (one over 10) the smart fields are fetch and visible. I think it's a problem in Ember. But i have no error in the console.
The Smart Field values injection is not made here (it is not the Serializer that does that job in the current liana).
To make the magic happen we should do improve this and it would make your code work perfectly.
By the way, is it a special relationship you have between users and letters? I don't get why Forest does not detect this relationship automatically.
Yes, it's a special one. Users does'n't contain an array of letters.