Primary key #1586
Primary key
#1586
-
Hi guys, i have a question. In my json i do not have an id field or a field with unique value(most of them are repeated). And i cannot compile my app without having a primary key. Is there a way to create an id for each json object inside table and assign it, or any other way i can have primary key without unique field? |
Beta Was this translation helpful? Give feedback.
Answered by
frankvollebregt
Dec 15, 2021
Replies: 1 comment
-
If you look at the 'declaring tables' section of the get started page link, you can declare an id which auto-increments yourself. class Todos extends Table {
IntColumn get id => integer().autoIncrement()(); // <-- this line right here
TextColumn get title => text().withLength(min: 6, max: 32)();
TextColumn get content => text().named('body')();
IntColumn get category => integer().nullable()();
} This way, any time an entry is pushed, an id should be incremented and set for it. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Akzqwerty
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you look at the 'declaring tables' section of the get started page link, you can declare an id which auto-increments yourself.
This way, any time an entry is pushed, an id should be incremented and set for it.