-
Notifications
You must be signed in to change notification settings - Fork 1.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
Setting Id field to auto-increment in mysql #2195
Comments
Set generated to true for db to seed ids: @property({
id: true,
generated: true,
description: 'The unique identifier for a product',
})
id: number; Same as lb3: https://loopback.io/doc/en/lb3/Model-definition-JSON-file.html |
Awesome, that works. I haven't tried LB3 since i just started with Loopback and i wanted to start with the latest ES. Any tips on the auth question ? Thanks! EDIT: One more question if i may, i'm assuming older Loopback components are not compatible with LB4 right? Such as storage component for uploading images/files through the api. |
Not production ready yet. See #1035 I think it's tabled for development Q1 2019. #1839 Can see example of concept: https://github.com/strongloop/loopback-next/tree/master/packages/authentication
I'm not sure, I've just come in for lb4. Maybe a project maintainer can answer that for you. |
Damn google surely isnt indexing that, couldnt find that information even tho' i searched for it the entire day. I guess i'll just sit back and wait for a better implementation since the package is giving me headaches and is not quite i'm looking for.
I took a closer look at lb3 and it seems that lb4 has been rewritten from scratch (used to be JS, now its TS) so i dont think it works. Thanks for the info! Appreciate it! |
This works! Ensure you Drop your table if it is not auto-updating :D |
Description / Steps to reproduce / Feature proposal
Create any model with an id number field.
Use MySQL connector.
Post once. Post twice. Second post does not get created in DB due to having the same id.
Current Behavior
The Id field of the model is not set to auto-increment in MySQL.
Expected Behavior
Id field should be set in the db to auto-increment (at least for MySQL)
Is there any way to do that if yes how? What i'd like is the ability to alter my DB when using
migrateSchema
or other pieces of LB4 code (auto migrate or auto update).The MySQL command is rather easy, for example
ALTER TABLE post CHANGE Id Id INT(11) NOT NULL AUTO_INCREMENT;
However i'd like to keep every DB change in LB4 instead of having to create a separate connection for my db.Can i add a service to do this for all my models that have an Id (every model should have an Id tho') ? Any tips on how? Pretty new to nodejs & LB4.
I hope i'm not breaking any rules by asking this here, but stackoverflow doesnt seem to be of any use and the documentation is still lacking in some parts (at least for not very experienced devs on node) .
Also...is there any good production ready example for authentication (JWT or other) that i could use? There's an example in the docs, but it says its not production ready and as i am still learning i'd like to use the best possible solution.
Thanks!
The text was updated successfully, but these errors were encountered: