Skip to content
This repository has been archived by the owner on May 19, 2020. It is now read-only.
/ i18n-go-postgre Public archive

Expending i18-go structures to bind them for PostgreSQL libs (gorm, lib/pq)

License

Notifications You must be signed in to change notification settings

microparts/i18n-go-postgre

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

i18n-go-postgre

Expending i18-go structures to bind them for PostgreSQL libs (gorm, lib/pq)

Usage

Translation

package pack

import (
	"database/sql"

	"github.com/jinzhu/gorm"
	"github.com/microparts/i18n-go/translation"
	translation_postgre "github.com/microparts/i18n-go-postgre/translation"
	
)

// A model definition

type Record struct {
	Id   int                `json:"id"`                  
	Name translation.String `json:"name"`
}

type RecordGorm struct {
	Id   int                        `json:"id"`                  
	Name translation_postgre.String `json:"name"`
}

func FetchRec(rows *sql.Result) (*Record, error) {
	record := &Record{}
	
	return record, rows.Scan(
	    &record.Id,
	    &translation_postgre.Bind{
		V: &record.Name,
	    },
	)
}

func Get(db *gorm.DB, id int) *RecordGorm {
	record := &RecordGorm{}

	db.First(record, id)
	
	return record
}

About

Expending i18-go structures to bind them for PostgreSQL libs (gorm, lib/pq)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages