Supports the following PartiQL statements:
- Select
- With Secondary Index
- With
begins_with
function - With
contains
function - With
size
function - With
attribute_type
function - With
MISSING
operator
- Insert
- Update
- With
SET
clause- With
list_append
function-
ListAppend()
-
- With
set_add
function - With
set_delete
function
- With
- With
REMOVE
clause
- With
- Delete
- Create Table ※ proprietary PartiQL syntax by
btnguyen2k/godynamo
- Create Index ※ proprietary PartiQL syntax by
btnguyen2k/godynamo
Supports the following GORM features:
-
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
-
Custom Clause:
SecondaryIndex
Custom Data Types:
-
Set[string | int | float64 | []byte]
-
List
-
Map
-
TypedList[T]
go get github.com/miyamo2/dynmgrm
package main
import (
"github.com/miyamo2/dynmgrm"
"gorm.io/gorm"
)
type Event struct {
Name string `gorm:"primaryKey"`
Date string `gorm:"primaryKey"`
Host string
Guest dynmgrm.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, ?)", dynmgrm.Set[string]{"Dave"}))
}
}
tx.Model(&carolBirthday).Update("guest", gorm.Expr("set_add(guest, ?)", dynmgrm.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.
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
-
dynmgrm
connects todatabase/sql
bybtnguyen2k/godynamo
. -
JetBrainsMono is used for the caption of the dynmgrm logo.