Skip to content

Primary key #1586

Answered by frankvollebregt
Akzqwerty asked this question in Q&A
Discussion options

You must be logged in to vote

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.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Akzqwerty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants