I use Payload CMS to update records in MongoDB. I noticed that when I use relationships to link different collections they are stored not as ObjectIds but as strings.
The code
{
name: 'occupationIds',
type: 'array',
label: 'Occupation',
required: true,
fields: [
{
name: 'occupationId',
type: 'relationship',
relationTo: 'occupations',
required: true,
},
],
}
results in a record
occupationIds: Array (2)
0: Object
occupationId: "66b280672a4e4285b87eb500"
id: "673b3b0d118c4d2064ef5cbb"
1: Object
occupationId: "66b280662a4e4285b87eb1d1"
id: "673b3b0d118c4d2064ef5cbc
My concern is that storing strings instead of an ObjectId will cause worse performance and slower querying. Can anything be done with it? Or there're no reasons to worry?