Skip to content

Yet Another Object–Relational Mapping, is a ORM using Go 1.18

License

Notifications You must be signed in to change notification settings

fiuskylab/yaorm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

yaORM

Yet Another Object–Relational Mapping, is a ORM using Go 1.18

Summary

  1. How To Use a. Defining Models

How To Use

Defining Models

You can declare a simple model using the following struct:

import (
  "github.com/fiuskylab/yaorm/model"
)
type User struct {
  model.Model
  Name  string `json:"name"`
  Email string `json:"email"`
}

The model.Model is:

// Model is the base for yaORM
type Model struct {
	ID        int       `json:"id" yaorm:"pk,autoincrement:true"`
	CreatedAt time.Time `json:"created_at" yaorm:"trigger:create"`
	UpdatedAt time.Time `json:"updated_at" yaorm:"trigger:update"`
	DeletedAt time.Time `json:"deleted_at" yaorm:"trigger:delete"`
}