Skip to content

An ORM library for Cassandra and ScyllaDB written in Golang.

License

Notifications You must be signed in to change notification settings

s4kibs4mi/jally-orm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JallyORM

An ORM library for Cassandra and ScyllaDB written in Golang.

Status : Development ongoing

Examples,

Connect,

config := gocql.NewCluster("localhost:9042")
config.Consistency = gocql.Quorum
config.Keyspace = "test"

config.Timeout = 5 * time.Second
config.PoolConfig = gocql.PoolConfig{
	HostSelectionPolicy: gocql.RoundRobinHostPolicy(),
}
config.NumConns = 5
orm, err := NewSession(config)

Sample Struct,

type Student struct {
	ID        gocql.UUID `json:"id" jorm:"primary_key"`
	Name      string     `json:"name"`
	Roll      int        `json:"roll"`
	CGPA      float32    `json:"cgpa"`
	IsPresent bool       `json:"is_present"`
	CreatedAt time.Time  `json:"created_at"`
}

Create Table,

orm, err := NewSession(config)
if err != nil {
	panic(err)
}
s := Student{}
q := NewQuery().Space("test").Table("students").Model(s)
err = orm.Create(q)

Insert value,

orm, err := NewSession(config)
if err != nil {
	panic(err)
}
s := Student{
	ID:        gocql.TimeUUID(),
	Name:      "Sakib",
	Roll:      12345,
	CGPA:      3.50,
	IsPresent: true,
	CreatedAt: time.Now(),
}
q := NewQuery().Space("test").Table("students").Model(s)
err = orm.Save(q)

License

Copyright © Sakib Sami

Distributed under MIT license

Releases

No releases published

Packages

No packages published

Languages