Skip to content

ubgo/gormuuid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gormuuid GitHub license

A Postgres uuid[] field for gorm.io

Installation

go get github.com/ubgo/gormuuid

How to use

type User struct {
  TagIDs gormuuid.UUIDArray  `gorm:"type:uuid[]"` // Column will take {} as default
}

var tagIds gormuuid.UUIDArray = []uuid.UUID{uuid.New(), uuid.New()}
db.Create(&User{
  TagIDs: tagIds,
})

Select Query

var users []User
tagId, _ := uuid.Parse("c4ba81a1-9e57-4e60-b811-2860136ab803")
db.Model(&User{}).Where("tag_ids && ?", pq.Array([]uuid.UUID{tagId})).Find(&users)

Examples

Contribute

If you would like to contribute to the project, please fork it and send us a pull request. Please add tests for any new features or bug fixes.

Stay in touch

License

goutil is MIT licensed.

About

Postgres uuid[] field for gorm.io - Golang

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages