Skip to content
This repository has been archived by the owner on Apr 14, 2024. It is now read-only.

ugurkorkmaz/mixin

Repository files navigation

ugurkorkmaz/mixin for ent orm.

go get github.com/ugurkorkmaz/mixin

google uuid mixin

package schema

import (
	"entgo.io/ent"
	"entgo.io/ent/schema/field"
	"github.com/ugurkorkmaz/mixin"
)

// User holds the schema definition for the User entity.
type User struct {
	ent.Schema
}

// Mixin of the User.
func (User) Mixin() []ent.Mixin {
	return []ent.Mixin{
		mixin.Id{},
	}
}

// Fields of the User.
func (User) Fields() []ent.Field {
	return []ent.Field{
		field.String("name"),
	}
}

creted at mixin

package schema

import (
	"entgo.io/ent"
	"entgo.io/ent/schema/field"
	"github.com/ugurkorkmaz/mixin"
)

// User holds the schema definition for the User entity.
type User struct {
	ent.Schema
}

// Mixin of the User.
func (User) Mixin() []ent.Mixin {
	return []ent.Mixin{
		mixin.CreatedAt{},
	}
}

// Fields of the User.
func (User) Fields() []ent.Field {
	return []ent.Field{
		field.String("name"),
	}
}

deleted at mixin

package schema

import (
	"entgo.io/ent"
	"entgo.io/ent/schema/field"
	"github.com/ugurkorkmaz/mixin"
)

// User holds the schema definition for the User entity.
type User struct {
	ent.Schema
}

// Mixin of the User.
func (User) Mixin() []ent.Mixin {
	return []ent.Mixin{
		mixin.DeletedAt{},
	}
}

// Fields of the User.
func (User) Fields() []ent.Field {
	return []ent.Field{
		field.String("name"),
	}
}

updated at mixin

package schema

import (
	"entgo.io/ent"
	"entgo.io/ent/schema/field"
	"github.com/ugurkorkmaz/mixin"
)

// User holds the schema definition for the User entity.
type User struct {
	ent.Schema
}

// Mixin of the User.
func (User) Mixin() []ent.Mixin {
	return []ent.Mixin{
		mixin.UpdatedAt{},
	}
}

// Fields of the User.
func (User) Fields() []ent.Field {
	return []ent.Field{
		field.String("name"),
	}
}
go mod tidy