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.

TypeError: Cannot read properties of undefined (reading 'fields')

default discord avatar
vqhdev4 weeks ago
1

Hello, I encountered the following issue when trying to edit data in the

join

field. If I set

collection

as an array, I get an error, but if I join to a single collection, it works fine:



Causes an error:

{
  name: 'assets',
  type: 'join',
  collection: ['digital-assets'],
  on: 'product',
}


Does not cause an error:

{
  name: 'assets',
  type: 'join',
  collection: 'digital-assets',
  on: 'product',
}


I’m not sure whether I’m doing something wrong or if this is a bug in Payload.

  • discord user avatar
    seanzubrickas
    4 weeks ago

    Hey

    @1111523060026183682

    this is an easy one, but I can see why it might cause confusion



    If you’re only ever joining one collection use a string:



    collection: 'digital-assets'

    Only use the array form when you truly need multiple collections (polymorphic join):



    collection: ['digital-assets', 'other-collection']

    when you pass an array, Payload treats the join as polymorphic, even if the array only has one collection

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.