-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Using Customization handler to insert app-generated ID #1021
Comments
I think it is because the code returns the insert(ed) id and not the primary key. |
So it doesn't matter if the inserted ULID is the primary key. Anyway, is multitenancy the correct way to do this or is there a better way? (aside from client-side ID generation) 😁 |
So i got it to return the new ULID by adding it in the afterHandler.
It's not very good-looking code but it kinda works for my use case. (Although I'm not sure if this is a correct way to use the $environment variable.)😁 |
Excellent, that is exactly how that I envisioned that it would be used! Keep it up.. |
Just noting here that the before/afterHandler does not work with user registration even though it's a POST request. |
@apps-caraga I would say that depends on the order of the middlewares. |
But it seems that no matter how I order the middlewares, the ULID is not inserted via the customization beforeHandler during dbAuth registration request. |
Did you load the Customization handler before DbAuth? You test for 'create' operation, while the DbAuth uses the 'unknown' if I read the code correctly. Did you debug the code? You should be able to do something when calling Customization before DbAuth. |
I think it cannot be done without modifying the dbAuth middleware |
Yup,that's the case.But it may not be a very common use case as of now. For now, I'll just copy some code in the register endpoint and insert it in my beforeHandler as a temp. workaround😁 For future, this feature might good to be implemented in an enhanced dbAuth middleware that can accept extra registration data. |
I was just trying to use Universally Unique Lexicographically Sortable Identifier ULID with this library and was able to insert the ULID via the multitenancy middleware as follows:
With SQLite, the post request is ok (data is saved and response status is HTTP 200) but returns {} or an empty array. Any idea why?
SQLite table schema:
The text was updated successfully, but these errors were encountered: