Skip to content

[Feature] Convert ORM to Table #23379

@Avey777

Description

@Avey777

Describe the feature

Like the 'ent' in the Go language, defined fields can be converted into tables in the database

Use Case

https://pkg.go.dev/entgo.io/ent#Field

type TimeMixin struct {}

func (TimeMixin) Fields() []ent.Field {
	return []ent.Field{
		field.Time("created_at").
			Immutable().
			Default(time.Now),
		field.Time("updated_at").
			Default(time.Now).
			UpdateDefault(time.Now),
	}
}

type T struct {
	ent.Schema
}

func(T) Mixin() []ent.Mixin {
	return []ent.Mixin{
		TimeMixin{},
	}
}

Proposed Solution

No response

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

Version used

0.4.9

Environment details (OS name and version, etc.)

Jengro@Jengro-PC:~/Documents/Dev/express-delivery-service$ v doctor
V full version: V 0.4.9 3953445
OS: linux, Deepin 23
Processor: 6 cpus, 64bit, little endian, Intel(R) Core(TM) i5-8500B CPU @ 3.00GHz

getwd: /home/Jengro/Documents/Dev/express-delivery-service
vexe: /home/Jengro/.vmr/versions/v_versions/v-0.4.9/v
vexe mtime: 2024-12-23 07:39:21

vroot: OK, value: /home/Jengro/.vmr/versions/v_versions/v-0.4.9
VMODULES: OK, value: /home/Jengro/.vmodules
VTMP: OK, value: /tmp/v_1000

Git version: git version 2.45.2
Git vroot status: Error: fatal: not a git repository (or any of the parent directories): .git
.git/config present: false

CC version: cc (Deepin 12.3.0-17deepin8) 12.3.0
emcc version: N/A
thirdparty/tcc: N/A
Jengro@Jengro-PC:~/Documents/Dev/express-delivery-service$

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions