如何在 Aqueduct 和 Postgres 中使用不同的 table 名称
How to have different table name in Aqueduct and in Postgres
我想在 Postgres 中使用 table 个名称,例如 "TableName"。在 Aqueduct 中,建议的 class 名称是 _tablename。
当我阅读 manual 时,我可以使用 @Table(name: "TableName") 但这似乎不起作用(或者可能没有被正确理解)。
有没有办法在 Postgres 中使用不同的 table 名称与 Aqueduct 中的私有 class 名称?
@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;
}
@Table()
注释必须应用于私有数据 class,在渡槽文档中称为 "table definition" class。在这种情况下,_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;
}
这是 Table class 上 api 文档的 link。
我想在 Postgres 中使用 table 个名称,例如 "TableName"。在 Aqueduct 中,建议的 class 名称是 _tablename。
当我阅读 manual 时,我可以使用 @Table(name: "TableName") 但这似乎不起作用(或者可能没有被正确理解)。
有没有办法在 Postgres 中使用不同的 table 名称与 Aqueduct 中的私有 class 名称?
@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;
}
@Table()
注释必须应用于私有数据 class,在渡槽文档中称为 "table definition" class。在这种情况下,_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;
}
这是 Table class 上 api 文档的 link。