dynmgrm is the driver to issue PartiQL Statement to DynamoDB with GORM⚡
- Select
- With Secondary Index
- With
begins_withfunction - With
containsfunction - With
sizefunction - With
attribute_typefunction - With
MISSINGoperator
- Insert
- Update
- With
SETclause- With
list_appendfunction-
ListAppend()
-
- With
set_addfunction - With
set_deletefunction
- With
- With
REMOVEclause
- With
- Delete
- Create Table ※ proprietary PartiQL syntax by
miyamo2/godynamo - Create GSI ※ proprietary PartiQL syntax by
miyamo2/godynamo
-
Query
-
Select -
Find -
Scan
-
-
Update
-
Update -
Updates -
Save
-
-
Create
-
Create
-
-
Delete
-
Delete
-
-
Condition
-
Where -
Not -
Or
-
-
Table/Model
-
Table -
Model※ Combination with Secondary Index are not supported.
-
-
Transaction ※ Supports only Insert, Update, and Delete.
-
Begin -
Commit -
Rollback -
Transaction
-
-
-
AutoMigrate -
CurrentDatabase -
FullDataTypeOf -
CreateTable -
DropTable -
HasTable -
GetTables -
HasColumn -
ColumnTypes -
CreateIndex -
DropIndex -
HasIndex
-
SecondaryIndex
dynamo-nested
What is about GORM Serializer?
go get github.com/miyamo2/dynmgrmTip
miyamo2/dynmgrm is recommended to be used in with miyamo2/sqldav.
miyamo2/sqldav provides Defined Type of slice/map that implements sql.Scanner and driver.Valuer.
These are as the equivalent to Set, List, Map and TypedList included in miyamo2/dynmgrm before v0.9.0.
package main
import (
"github.com/miyamo2/dynmgrm"
"github.com/miyamo2/sqldav"
"gorm.io/gorm"
)
type Event struct {
Name string `gorm:"primaryKey"`
Date string `gorm:"primaryKey"`
Host string
Guest sqldav.Set[string]
}
func main() {
db, err := gorm.Open(dynmgrm.New())
if err != nil {
panic(err)
}
var dynamoDBWorkshop Event
db.Table("events").
Where(`name=?`, "DynamoDB Workshop").
Where(`date=?`, "2024/3/25").
Scan(&dynamoDBWorkshop)
dynamoDBWorkshop.Guest = append(dynamoDBWorkshop.Guest, "Alice")
db.Save(&dynamoDBWorkshop)
carolBirthday := Event{
Name: "Carol's Birthday",
Date: "2024/4/1",
Host: "Charlie",
Guest: []string{"Alice", "Bob"},
}
db.Create(carolBirthday)
var daveSchedule []Event
db.Table("events").
Where(`date=?`, "2024/4/1").
Where(`( ? )`,
db.Where(`host=?`, "Dave").Or(`CONTAINS("guest", ?)`, "Dave")).
Scan(&daveSchedule)
tx := db.Begin()
for _, event := range daveSchedule {
if event.Host == "Dave" {
tx.Delete(&event)
} else {
tx.Model(&event).Update("guest", gorm.Expr("set_delete(guest, ?)", sqldav.Set[string]{"Dave"}))
}
}
tx.Model(&carolBirthday).Update("guest", gorm.Expr("set_add(guest, ?)", sqldav.Set[string]{"Dave"}))
tx.Commit()
var hostDateIndex []Event
db.Table("events").Clauses(
dynmgrm.SecondaryIndex("host-date-index"),
).Where(`host=?`, "Bob").Scan(&hostDateIndex)
}Feel free to open a PR or an Issue.
However, you must promise to follow our Code of Conduct.
See here for more details on contributing.
dynmgrm released under the MIT License
The Go gopher was designed by Renee French. The design is licensed under the Creative Commons 3.0 Attributions license. Read this article for more details
-
dynmgrmconnects todatabase/sqlbymiyamo2/godynamothat forked frombtnguyen2k/godynamo. -
JetBrainsMono is used for the caption of the dynmgrm logo.