Skip to content

1.0.0 - Initial Release

Latest

Choose a tag to compare

@scrothers scrothers released this 21 Dec 08:25
· 6 commits to main since this release

dynorm v1.0.0

We're excited to announce the first stable release of dynorm - a lightweight, expressive DynamoDB abstraction layer for Go.

Features

Core ORM Functionality

  • Entity-based modeling with embedded Entity struct providing ID, timestamps, and soft delete support
  • Generic Repository pattern with type-safe CRUD operations
  • Fluent Query Builder with chainable methods for filtering, ordering, and projection
  • Batch operations for efficient multi-item reads and writes
  • Transactions with automatic retry and error handling
  • Cursor-based pagination with iterator support for streaming large result sets

Relationships

  • HasOne / HasMany - One-to-one and one-to-many relationships
  • BelongsTo / BelongsToMany - Inverse and many-to-many relationships with pivot tables
  • HasManyThrough - Nested relationships through intermediate entities
  • Polymorphic relationships - MorphOne, MorphMany, MorphToMany, MorphedByMany
  • Eager loading with With() to prevent N+1 queries
  • Cascade delete options for automatic cleanup of related entities

Validation

  • Built-in validators: required, min, max, email, url, uuid, regex, and more
  • Enum validation with interface support
  • Custom validation rules via struct tags
  • Detailed validation error messages with field paths

Events & Lifecycle Hooks

  • Full lifecycle event support: Creating, Created, Updating, Updated, Saving, Saved
  • Delete events: Deleting, Deleted, Trashing, Trashed (soft delete)
  • Restore events: Restoring, Restored
  • Replication events: Replicating, Replicated

Schema & Marshaling

  • Automatic snake_case conversion for DynamoDB attributes
  • Support for GSI (Global Secondary Index) configuration via struct tags
  • JSON marshaling/unmarshaling with proper type handling
  • Time handling with ISO 8601 format

Collections

  • Rich collection API with Map, Filter, Reduce, GroupBy, Pluck
  • Sorting, chunking, and partitioning
  • Statistical methods: Sum, Avg, Min, Max

Installation

go get github.com/go-gamma/dynorm

Quick Start

package main

import (
    "context"
    "github.com/go-gamma/dynorm"
)

type User struct {
    dynorm.Entity
    Name  string `validate:"required,min=2"`
    Email string `validate:"required,email"`
    Posts dynorm.HasMany[*PostRepository]
}

type UserRepository struct {
    dynorm.Repository[User]
}

func main() {
    // Initialize with your DynamoDB client
    dynorm.SetClient(dynamoDBClient)

    repo := &UserRepository{}

    // Create
    user := &User{Name: "John", Email: "john@example.com"}
    repo.Save(user)

    // Query
    users, _ := repo.Where("name", "=", "John").Get()

    // With relationships
    user, _ := repo.With("Posts").Find(id)
}

Documentation

Full documentation available at https://go-gamma.github.io/dynorm