General question, but what is the difference between setting an array and a "hasMany: true"?
@shisue do you mean hasMany: true on the number field?
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?
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
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
Discord
online
Get help straight from the Payload team with an Enterprise License.