Relationship Object String to ObjectID

default discord avatar
Rarcif
4 weeks ago
4

Hi,



I have noticed that the object ID is stored as a string in MongoDB. Is there a way to store it as ObjectID? It would be easier if the type is ObjectID for easier lookups.



I am referring to the tutorial here:



https://payloadcms.com/docs/fields/relationship


Anyone?

  • discord user avatar
    jmikrut
    Payload Team
    3 weeks ago

    Hey @Rarcif — we store object IDs as strings intentionally, and there is no real easy way to store them as full ObjectIDs. This is for a few reasons, but we could certainly evaluate a way to be able to "opt in" to ObjectIDs instead of string representations in a new feature



    there are a few places in the code that would need to be adjusted, but technically, this could be doable with a PR



    right now, it's not possible though

Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.