Skip to content

Dynamoid/dynamoid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1,984 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dynamoid

Gem Version Supported Build Status Maintainability Coveralls CodeCov Helpers Contributors RubyDoc.info License GitMoji SemVer 2.0.0 Keep-A-Changelog 1.0.0 Sponsor Project

A feature-rich and powerful Ruby ORM for Amazon DynamoDB, designed to provide a familiar ActiveRecord-like experience for Ruby applications.

Key Features

  • ActiveRecord-style DSL: Implements an interface and configuration similar to Rails' ActiveRecord.
  • Querying & Persistence: Provides methods for finding, querying, and updating models.
  • Advanced ORM Features: Supports associations, callbacks, validations, Dirty API, optimistic locking, and type casting.
  • Additional Attribute Types: Supports types not natively provided by Amazon DynamoDB, such as DateTime, Time, and more.
  • Transactions: Supports Amazon DynamoDB transactional operations.

Quick start

Installation

Add Dynamoid to your Gemfile:

gem 'dynamoid'

Or install it using bundle:

bundle add dynamoid

Alternatively, you can install the gem manually:

gem install dynamoid

Usage

To define a model, include Dynamoid::Document and declare your fields. Dynamoid supports ActiveModel validations and automatic timestamps:

class User
  include Dynamoid::Document

  field :name                        # Type defaults to :string
  field :email
  field :age, :integer
  field :active, :boolean, default: true

  validates :name, presence: true
  validates :email, format: { with: /@/ }
end

Once defined, you can interact with your models using a familiar API:

# Create and Save
user = User.create(name: 'Josh', email: 'josh@example.com')

# Find and Update
user = User.where(email: 'josh@example.com').first
user.update_attributes(age: 30)

# Querying
users = User.where(active: true).all.to_a

Essential Configuration

Minimal connection settings are required. You can configure Dynamoid in several ways, such as in config/initializers/dynamoid.rb (for Rails) or directly in your setup:

require 'dynamoid'

Dynamoid.configure do |config|
  config.access_key = 'REPLACE_WITH_ACCESS_KEY_ID'
  config.secret_key = 'REPLACE_WITH_SECRET_ACCESS_KEY'
  config.region = 'REPLACE_WITH_REGION' # e.g. 'us-west-2'
end

Documentation

  • API Reference: Comprehensive documentation for all classes and methods is available on RubyDoc.info.
  • User Guides: For detailed overviews and usage examples of specific features, see the online User Guides.

Compatibility

Dynamoid relies on aws-sdk-dynamodb (AWS SDK v3) and activemodel (>= 4.2). It officially supports Ruby >= 2.3 and Rails >= 4.2.

Compatibility is tested against the following versions:

  • Ruby: 2.3 - 4.0 (including JRuby 10.x)
  • Rails: 4.2 - 8.1

Contributing

We welcome contributions to Dynamoid! Please see our CONTRIBUTING.md guide for details on how to get started. Join us!

Security

See SECURITY.md.

License

The gem is available as open source under the terms of the MIT License License: MIT. See LICENSE for the official Copyright Notice.

Credits

Dynamoid borrows code, structure, and even its name very liberally from the truly amazing Mongoid. Without Mongoid to crib from none of this would have been possible, and I hope they don't mind me reusing their very awesome ideas to make Amazon DynamoDB just as accessible to the Ruby world as MongoDB.

Also, without contributors the project wouldn't be nearly as awesome. So many thanks to:

* Current Maintainers

About

Ruby ORM for Amazon's DynamoDB.

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages