hasMany Smart Relationship not loading

Hi,

I encounter an issue loading one specific smart relationship and I can’t find the reason.

I have 2 smart collections (Client and Driver) based on the same real collection (User).
The schema for each smart collection is quite similar. The mail difference are filters and other specific display.
I have already succesfully implemented smart relationship for each of them.
But when I try to add a new has many smart relationship (notificationList), it works fine with my client smart collection but not with my driver smart collection.

I have implemented the relatioships the same way for each collection:

                {
                    field: 'notificationsList',
                    type: ['String'],
                    reference: 'Notification._id'
                }

The UI link display fine but in the case of the drivers, no endpoints are called (see screenshots enclosed).

Client:

Driver:

Can you help me understand what is wrong ?

Context

  • “database_type”: “MongoDB”,
  • “liana”: “forest-express-mongoose”,
  • “liana_version”: “6.3.0”,
  • “engine”: “nodejs”,
  • “engine_version”: “10.19.0”,
  • “orm_version”: "5.8.5

Hi @Florian_Belliard :wave: thank you for your feedback.

Can you provide me the declaration of your User collection and the definition of your Client and Driver smart collection please. It would help me to reproduce.

Have you got any error on your browser console ?

Hello @Florian_Belliard :wave:

Do you observe this issue on the client collection sometimes or only in the driver one ?

Steve.

It happens only on the driver collection everytime. The client collection works fine.

Hi @Florian_Belliard could you also share with us the way you serialize drivers list response?

If no request is triggered by the browser when you access the “notificationsList”, it is probably because the resource link to “notificationsList” is not transmitted or well serialized in the drivers context.
(If it works for clients, it is probably well serialized in this case).

Hi @arnaud,

I’m serializing the notificationsList exactly the same way in clients or drivers case. It’s the same endpoint that is called.

const JSONAPISerializer = require('jsonapi-serializer').Serializer;

...

let serializer = new JSONAPISerializer('Notification', {
            attributes: ['name', 'topic', 'type', 'inAppBehavior', 'createdAt', 'userStatus', 'userStatusChangedAt'],
            keyForAttribute: 'camelCase',
            meta: { "count": _.size(user.notifications) }
});

res.send(serializer.serialize(notifications));

I have just updated the way I serialize drivers and clients using the Liana.ResourceSerializer as you describe it in your documentation.

        let serializedNotifications = await new Liana.ResourceSerializer(
            Liana,
            Notification.getMongooseModel(),
            notifications,
            null,
            { count: totalRecords }
        ).perform();

        res.send(serializedNotifications);

But the issue stays the same. Works fine for clients and not for drivers.

@Florian_Belliard thank you for sharing the Serializer definition.

Unfortunately I haven’t been able ro reproduce on my end.

As Arnaud said, knowing that the requests is not sent means there is an issue on the retrieval of the Drivers. To see which difference there might be, could you share with me the get route implementation for both the Drivers and Clients collection?

Thank you

Ok I fixed my issue. Since it’s a smart collection, I had to send the notificationList as a relationships in the response of the getOne endpoint…

Thanks for your help !

1 Like

I seem to be having a very similar issue. After updating from v4 all the way to v7 none of my smart relationships seem to be loading anything, and there is no requests being made either in the network tab.

If someone could elaborate of the solution a bit, I would be really appreciate it.

Thank you

Hello! If anyone solved it, please share an example :pray:
I’ve tried everything that came up to my mind but I still couldn’t make it work

Solved my issue, please see topic here: Smart relationship for a smart collection