Allow usage of custom id in collections #262
Replies: 5 comments 7 replies
-
Hey @jeanbmar — this is a great idea and the Payload team certainly sees the value in this being a new feature to add. We've actually got a project running now that would also benefit from this 😎 . We also like your suggestions about how the API would function, via a deliberate Looks like MongoDB supports it too. However, as we use Mongoose under the hood, we would need to ensure that Mongoose's This may be a relatively complex change... And it would certainly need to be very thoroughly tested. If you and your team would like to take a stab at it, by all means, we would support you! However, we'd be happy to slate this into our own workload as well. We have a list of priorities at the moment, including some pretty exciting stuff, so this might take us a few months to tackle. But we'd be happy to do it. What do you think? |
Beta Was this translation helpful? Give feedback.
-
Hey, newbie mongoDB user here. Why would you not want to use the object ids? I kind of get the importing data thing but I'm interested to understand why it's an issue otherwise. |
Beta Was this translation helpful? Give feedback.
-
@jmikrut I'm almost done and should be able to submit a PR with a small footprint within 1-2 days. |
Beta Was this translation helpful? Give feedback.
-
Opened #266 |
Beta Was this translation helpful? Give feedback.
-
Awesome! 🎉🎉 |
Beta Was this translation helpful? Give feedback.
-
First, a few words about our use case: we load payload with a bunch of external data generated programmatically by a 3rd party system, and we give a few users the power to override some of the data.
Using mongodb generated ids implies a pretty bad overhead, because we have to insert all the records in the collections, and rebuild and update all the relationships between them afterward by retrieving all the documents, using alternate keys / indices, etc.
Ideally, we would like to be able to specify our own unique ids as a replacement of the standard ObjectId when submitting records. By doing so, we could load the records easily together with their relationships.
We are willing to work on a PR if you agree with this idea.
A possible way to do it could be through an explicit
id
field in collection definitions.Payload could then act accordingly when:
What are your thoughts on this?
Beta Was this translation helpful? Give feedback.
All reactions