1

I want to use table names in Postgres like "TableName". In Aqueduct the suggested class name is _tablename.

As I read the manual I can use @Table(name: "TableName") but that doesn't seem to work (or probably not understood correctly).

Is there a way to use a different table name in Postgres versus the private class name in Aqueduct?

@Table(name: "UserName")
class User extends ManagedObject<_User> implements _User {
  @Serialize()
  String get fullname => '$firstname $lastname';

  @override
  void willUpdate() {
    // Add anything here to change prior to being updated.
  }

  @override
  void willInsert() {
    // Add anything here to change prior to being inserted.
  }
}

class _User {
  @primaryKey
  int id;
  @Column(nullable: false)
  String firstname;
  @Column(nullable: false)
  String lastname;
  @Column(nullable: false)
  String email;
}
Adri
  • 23
  • 4

1 Answers1

0

The @Table() annotation must be applied to the private data class which is referred to in the aqueduct documentation as the "table definition" class. In this case, the _User class:

@Table(name: "UserName")
class _User {
  @primaryKey
  int id;
  @Column(nullable: false)
  String firstname;
  @Column(nullable: false)
  String lastname;
  @Column(nullable: false)
  String email;
}

Here's a link to the api docs on the Table class.

hola
  • 3,150
  • 13
  • 21