-
|
Does anyone have any experience implementing hashid'd autoincrementing IDs with Prisma? We have a schema that uses autoincrementing IDs throughout but would like to use hashids to encode/decode IDs when they become "public facing". Right now, we have a rather hacky internal library that tracks all of our known ID property names and encodes/decodes them automatically, but it's becoming quite cumbersome to use. However, if there isn't anything out there, I'd love to sit down and refactor our internal library into something that could be open-sourced. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
|
Hey @lukecarr 👋, I don't have any experience with hashids specifically, but it sounds like you might want to look at our middleware API. It offers quite a bit of flexibility and I think you could come up with a solution whether you want to store the hashids or store plain IDs and hash them on read. Let me know if I can answer any more specific questions you have! |
Beta Was this translation helpful? Give feedback.
-
|
Hi there, To keep our discussions organized and focused on the most relevant topics, we’re reviewing and tidying up our backlog. As part of this process, we’re closing discussions that have already been marked as answered but remain open. If this discussion still requires further input or clarification, feel free to reopen it or start a new one with updated details. Your contributions are invaluable to the community, and we’re here to help! For more details about our priorities and vision for the future of Prisma ORM, check out our latest blog post: https://www.prisma.io/blog/prisma-orm-manifesto. Thank you for your understanding and ongoing support of the Prisma community! |
Beta Was this translation helpful? Give feedback.
We're looking to implement an ID system similar to Stripe's where each model has a unique PK prefix.
However, we'd still like to use auto-incrementing IDs at the database level, so right now we're using hashids at the application layer to encode/decode each model's ID fields (and prepend the correct prefix). Naturally, we also need to encode/decode any FK fields for a model in other models.
Right now, are internal lib comprises of a register to keep track of all models, their PK prefixes, and their FK fields in other models. It also has an encode/decode function for transforming an object (looking at the register and encoding/decoding