mixin

package module
v1.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 17, 2023 License: MIT Imports: 7 Imported by: 0

README

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreatedAt

type CreatedAt struct {
	mixin.Schema
}

CreatedAt mixin for the created_at field.

func (CreatedAt) Fields

func (CreatedAt) Fields() []ent.Field

Fields of the CreatedAt mixin.

type DeletedAt

type DeletedAt struct {
	mixin.Schema
}

DeletedAt mixin for the deleted_at field.

func (DeletedAt) Fields

func (DeletedAt) Fields() []ent.Field

Fields of the DeletedAt mixin.

type Id

type Id struct {
	mixin.Schema
}

UUID is a mixin that adds a UUID field to an entity.

func (Id) Fields

func (Id) Fields() []ent.Field

Fields of the UUID mixin.

type UpdatedAt

type UpdatedAt struct {
	mixin.Schema
}

UpdatedAt mixin for the updated_at field.

func (UpdatedAt) Fields

func (UpdatedAt) Fields() []ent.Field

Fields of the UpdatedAt mixin.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL