dart-backend / angel

A polished, production-ready backend framework in Dart for the VM, AOT, and Flutter.
https://github.com/dukefirehawk/angel
BSD 3-Clause "New" or "Revised" License
171 stars 22 forks source link

angel3_orm MySQL/MariaDB auto increment #122

Open Garthi opened 2 months ago

Garthi commented 2 months ago

Hello, we are currently searching for an ORM plugin for our new DART project and we tested the angel3_orm. But we can't find an auto increment definition for the entity.

Does it really not exist in your ORM or did we just not find the correct way to implement it? Could you give me some feedback regarding this matter? Thank you!

dukefirehawk commented 2 months ago

Have you tried the following?

@primayKey int? id;

Take a look at the examples in packages/orm/angel_orm_test.

Garthi commented 2 months ago

Hi, we found two solutions one is

  @Column(type: ColumnType.serial, indexType: IndexType.primaryKey)
  int? get id;

but with this version you can't add references, then the type alias generates a big int the second solution is

  @Column(type: ColumnType.int, indexType: IndexType.primaryKey, length: 10, defaultValue: 'NULL AUTO_INCREMENT')
  int? get id;

this version is a bit hacki but is works for us :-)

dukefirehawk commented 2 months ago

The first solution should work. Will schedule it to be fixed.