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.

General question, but what is the difference betwe...

discord user avatar
alessiogr
last year
3
@217300665473564672

do you mean hasMany: true on the number field?

  • default discord avatar
    igormfelast year

    Yea, something like:



    {


    name: 'projects',


    label: 'Projects',


    type: 'relationship',


    relationTo: 'projects',


    hasMany: true,


    }



    vs



    {


    name: 'projects',


    label: 'Projects',


    type: 'array',


    ...


    }



    Is array just a way of having fields that have different types (polymorphic), while hasMany:true will make an array regardless, but of a single type?

  • discord user avatar
    alessiogr
    last year

    Nope! Relationships can be polymorphic as well!



    The difference is that for the array, the project would be saved IN that array field. Like, it's part of the document.



    For the hasMany relationship, the project would be saved in another document in the projects collection

  • default discord avatar
    igormfelast year

    I see, that makes sense! So, does that affect query time? Let's say I have organizations, which has many projects. If I want to store it as "hasMany" and query organizations, how would that query work?

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.