Select first image in one-to-many relationship

I am building say an AirBnb like app where each site can have multiple images.

I have two collection, “Site” and “Site images” where “Site” has a one-to-many relationship with “Site-images”, ie that there are several pictures for one site and one pix only belongs to one single site.

It works well but I am facing an infinite loop when I try to display only one single image (say the first one) in a simple list with Image on the left, see screenshot.

How to display one image from the Site images collection in this case?


So Adalo won’t show you an image to pick because there are multiple possible images. That being the case, Adalo expects you to use a list for this.

Right now you have a simple list. Change this to custom list. Then make the image a list within a list, limited to 1 result.

Another option is to have a second relationship (not many to many) for ‘primary image’. This should allow you to display this primary image in the way you are trying there, and you’d be able to display the other images elsewhere sehwre using a list.

1 Like

I will use the “featured image” option though it is not possible to define a one-to-one relationship. I have had to use a many-to-one, ie that a site has only one single feature image but the same featured image could be used for several sites, which makes no sense.

Is there some one who find a solution for this issue. In my case I have a relation between products and images. 1 product have many images. When i try to do the same as @clemlaflemme I have the same issue ?

Clement, tu as peut être trouvé entre temps ?

You need to use a list.

List of images, current product > images.

If you want one a featured image you could have a true/false property ‘featured image’ and filter the list for that too