Move code
This commit is contained in:
parent
00f2e125df
commit
6203d967eb
@ -7,5 +7,5 @@ publish = false
|
||||
[dependencies]
|
||||
async-std = { version = "^1.9", features = [ "attributes" ] }
|
||||
sea-orm = { path = "../../", features = [ "sqlx-mysql", "runtime-async-std-native-tls", "debug-print" ] }
|
||||
sea-query = { path = "../../../sea-query" }
|
||||
# sea-query = { path = "../../../sea-query" }
|
||||
strum = { version = "^0.20", features = [ "derive" ] }
|
@ -35,6 +35,40 @@ impl EntityTrait for Entity {
|
||||
type Relation = Relation;
|
||||
}
|
||||
|
||||
impl ColumnTrait for Column {
|
||||
type EntityName = Entity;
|
||||
|
||||
fn def(&self) -> ColumnType {
|
||||
match self {
|
||||
Self::Id => ColumnType::Integer(None),
|
||||
Self::Name => ColumnType::String(None),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl RelationTrait for Relation {
|
||||
fn def(&self) -> RelationDef {
|
||||
match self {
|
||||
Self::Fruit => Entity::has_many(super::fruit::Entity)
|
||||
.from(Column::Id)
|
||||
.to(super::fruit::Column::CakeId)
|
||||
.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Related<super::fruit::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::Fruit.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl Model {
|
||||
pub fn find_fruit(&self) -> Select<super::fruit::Entity> {
|
||||
Entity::find_related().belongs_to::<Entity>(self)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: implement with derive macro
|
||||
impl EntityName for Entity {}
|
||||
|
||||
@ -95,17 +129,6 @@ impl IdenStatic for Column {
|
||||
}
|
||||
}
|
||||
|
||||
impl ColumnTrait for Column {
|
||||
type EntityName = Entity;
|
||||
|
||||
fn def(&self) -> ColumnType {
|
||||
match self {
|
||||
Self::Id => ColumnType::Integer(None),
|
||||
Self::Name => ColumnType::String(None),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: implement with derive macro
|
||||
impl Iden for PrimaryKey {
|
||||
fn unquoted(&self, s: &mut dyn std::fmt::Write) {
|
||||
@ -133,26 +156,3 @@ impl PrimaryKeyOfModel<Model> for PrimaryKey {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl RelationTrait for Relation {
|
||||
fn def(&self) -> RelationDef {
|
||||
match self {
|
||||
Self::Fruit => Entity::has_many(super::fruit::Entity)
|
||||
.from(Column::Id)
|
||||
.to(super::fruit::Column::CakeId)
|
||||
.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Related<super::fruit::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::Fruit.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl Model {
|
||||
pub fn find_fruit(&self) -> Select<super::fruit::Entity> {
|
||||
Entity::find_related().belongs_to::<Entity>(self)
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,24 @@ impl EntityTrait for Entity {
|
||||
type Relation = Relation;
|
||||
}
|
||||
|
||||
impl ColumnTrait for Column {
|
||||
type EntityName = Entity;
|
||||
|
||||
fn def(&self) -> ColumnType {
|
||||
match self {
|
||||
Self::Id => ColumnType::Integer(None),
|
||||
Self::Name => ColumnType::String(None),
|
||||
Self::CakeId => ColumnType::Integer(None),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl RelationTrait for Relation {
|
||||
fn def(&self) -> RelationDef {
|
||||
panic!()
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: implement with derive macro
|
||||
impl EntityName for Entity {}
|
||||
|
||||
@ -99,17 +117,6 @@ impl IdenStatic for Column {
|
||||
}
|
||||
}
|
||||
|
||||
impl ColumnTrait for Column {
|
||||
type EntityName = Entity;
|
||||
|
||||
fn def(&self) -> ColumnType {
|
||||
match self {
|
||||
Self::Id => ColumnType::Integer(None),
|
||||
Self::Name => ColumnType::String(None),
|
||||
Self::CakeId => ColumnType::Integer(None),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: implement with derive macro
|
||||
impl Iden for PrimaryKey {
|
||||
@ -138,9 +145,3 @@ impl PrimaryKeyOfModel<Model> for PrimaryKey {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl RelationTrait for Relation {
|
||||
fn def(&self) -> RelationDef {
|
||||
panic!()
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,40 @@ impl EntityTrait for Entity {
|
||||
type Relation = Relation;
|
||||
}
|
||||
|
||||
impl ColumnTrait for Column {
|
||||
type EntityName = Entity;
|
||||
|
||||
fn def(&self) -> ColumnType {
|
||||
match self {
|
||||
Self::Id => ColumnType::Integer(None),
|
||||
Self::Name => ColumnType::String(None),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl RelationTrait for Relation {
|
||||
fn def(&self) -> RelationDef {
|
||||
match self {
|
||||
Self::Fruit => Entity::has_many(super::fruit::Entity)
|
||||
.from(Column::Id)
|
||||
.to(super::fruit::Column::CakeId)
|
||||
.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Related<super::fruit::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::Fruit.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl Model {
|
||||
pub fn find_fruit(&self) -> Select<super::fruit::Entity> {
|
||||
Entity::find_related().belongs_to::<Entity>(self)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: implement with derive macro
|
||||
impl EntityName for Entity {}
|
||||
|
||||
@ -95,17 +129,6 @@ impl IdenStatic for Column {
|
||||
}
|
||||
}
|
||||
|
||||
impl ColumnTrait for Column {
|
||||
type EntityName = Entity;
|
||||
|
||||
fn def(&self) -> ColumnType {
|
||||
match self {
|
||||
Self::Id => ColumnType::Integer(None),
|
||||
Self::Name => ColumnType::String(None),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: implement with derive macro
|
||||
impl Iden for PrimaryKey {
|
||||
fn unquoted(&self, s: &mut dyn std::fmt::Write) {
|
||||
@ -133,26 +156,3 @@ impl PrimaryKeyOfModel<Model> for PrimaryKey {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl RelationTrait for Relation {
|
||||
fn def(&self) -> RelationDef {
|
||||
match self {
|
||||
Self::Fruit => Entity::has_many(super::fruit::Entity)
|
||||
.from(Column::Id)
|
||||
.to(super::fruit::Column::CakeId)
|
||||
.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Related<super::fruit::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::Fruit.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl Model {
|
||||
pub fn find_fruit(&self) -> Select<super::fruit::Entity> {
|
||||
Entity::find_related().belongs_to::<Entity>(self)
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,24 @@ impl EntityTrait for Entity {
|
||||
type Relation = Relation;
|
||||
}
|
||||
|
||||
impl ColumnTrait for Column {
|
||||
type EntityName = Entity;
|
||||
|
||||
fn def(&self) -> ColumnType {
|
||||
match self {
|
||||
Self::Id => ColumnType::Integer(None),
|
||||
Self::Name => ColumnType::String(None),
|
||||
Self::CakeId => ColumnType::Integer(None),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl RelationTrait for Relation {
|
||||
fn def(&self) -> RelationDef {
|
||||
panic!()
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: implement with derive macro
|
||||
impl EntityName for Entity {}
|
||||
|
||||
@ -99,17 +117,6 @@ impl IdenStatic for Column {
|
||||
}
|
||||
}
|
||||
|
||||
impl ColumnTrait for Column {
|
||||
type EntityName = Entity;
|
||||
|
||||
fn def(&self) -> ColumnType {
|
||||
match self {
|
||||
Self::Id => ColumnType::Integer(None),
|
||||
Self::Name => ColumnType::String(None),
|
||||
Self::CakeId => ColumnType::Integer(None),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: implement with derive macro
|
||||
impl Iden for PrimaryKey {
|
||||
@ -138,9 +145,3 @@ impl PrimaryKeyOfModel<Model> for PrimaryKey {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl RelationTrait for Relation {
|
||||
fn def(&self) -> RelationDef {
|
||||
panic!()
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user