storage/

directory
v1.24.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 8, 2024 License: MIT

README

x/storage - Golang schemaless orm with union type support

Make working with data types in golang easy and simple. Focus on business logic, that differentiate your needs, not serialization and deserialization.

type MyRecord struct {
	Age int
	Name string
}

store := schemaless.NewInMemoryRepository()
//store := schemaless.NewDynamoDBRepository(dynamodb.NewFromConfig(cfg), tableName)
//store := NewOpenSearchRepository(client, indexName)

// make working with records type safe
repo := typedful.NewTypedRepository[MyRecord](store)
state, err := repo.Get("1", "user")
assert.ErrorIs(t, err, schemaless.ErrNotFound)

err = repo.UpdateRecords(schemaless.Save(schemaless.Record[MyRecord]{
    ID:   "1",
    Type: "user",
    Data: MyRecord{...},
}))
assert.NoError(t, err)

result, err := repo.FindingRecords(FindingRecords[Record[MyRecord]]{
    Where: predicate.MustWhere(
        "Data.#.Age > :age",
        predicate.ParamBinds{
            ":age": schema.MkInt(20),
        },
    ),
    Sort: []SortField{
        {
            Field:      "Data.#.Name",
            Descending: false,
        },
    },
})

Roadmap

V0.1.0
  • x/storage support DynamoDB, OpenSearch, and InMemory implementation

Directories

Path Synopsis
Code generated by mkunion.
Code generated by mkunion.
Code generated by mkunion.
Code generated by mkunion.
projection
Code generated by mkunion.
Code generated by mkunion.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL