Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

how to shown the relationship of another collection on the admin page

default discord avatar
megetron_2 years ago
1

trying to display the products on the collection admin page.


in the database , the products collection saves all collections it is belongs to.



i would like to see all the products from the collection view. what would be best to achieve this?



const products: CollectionConfig = {
  slug: "products",
  fields: [
    {
      name: "collections",
      type: "relationship",
      relationTo: "collections",
      hasMany:true
    },
  ],
};

const collections: CollectionConfig = {
  slug: 'collections',
  fields: [
    {
      name: 'id',
      type: 'text',
    },

    // {
    //   name: 'products',
    //   type: 'relationship',
    //   relationTo: 'products',
    //   hasMany: true
    // },
  ],
}
Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.