-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there a way of generating nanoids through the ESDL file? #1010
Comments
function createFoo(data) {
return e.insert(e.Foo, {
nano_id: nanoid(),
...data,
}).run(client);
} Making this a generic helper is left as an exercise for the reader 😅 I'd probably just have some function that inserts a nanoid at a default (overridable) key in a source object to abstract out the nanoid insertion. Or really, I'd just do it inline in the places I want them. It's on our medium-term radar to add some higher level wrappers for doing more generic/abstract things that go beyond just mapping EdgeQL to TypeScript, and we'd probably want to have some similar thing affordance within that context in the future. |
Thank you for the quick response! It's just that I find Drizzle's option of setting up custom functions from TypeScript incredibly practical, and it helps cleaning up the code quite a bit to setup defaults like that. |
+1 to everything in this thread. When I was using drizzle, I used Looks like there is a postgres extension for this And it looks like the question has been asked to other postgres providers as well |
I would like to have an extra, short nanoid for one of my tables. How do I do that? Is it possible to do it through the
.esdl
file?On Drizzle, for example, I do something like this:
That's TypeScript, but there are PostgreSQL implementations of it, like viascom/nanoid-postgres.
Anyway, my question is not about nanoid specifically, but about how to do a custom ID.
The text was updated successfully, but these errors were encountered: