Code Monkey home page Code Monkey logo

dymos's Introduction

Dymos

Build Status Coverage Status

dynamodb model

Installation

Add this line to your application's Gemfile:

gem 'dymos'

install it yourself as:

$ gem install dymos

Usage

テーブル生成

Dymos::Query::CreateTable.name('ProductCatalogs')
  .attributes(category: 'S', title: 'S', ISBN:'S', price:'N')
  .keys(category: 'HASH', title: 'RANGE')
  .gsi([{name: 'global_index_isbn', keys: {ISBN: 'HASH'}, projection: {type: 'INCLUDE', attributes: [:title, :ISBN]}, throughput: {read: 20, write: 10}}])
  .lsi([{name: 'local_index_category_price', keys: {category: 'HASH', price: 'RANGE'}}])
  .throughput(read: 20, write: 10)

モデル定義

class Product < Dymos::Model
    table 'ProductCatalogs'
    field :category, :integer
    field :title, :string
    field :ISBN, :string
    field :price, :integer
    field :authors, :array
    field :created_at, :time
  end

クエリ

取得

Product.all
Product.find('Novels', 'The Catcher in the Rye') #key is category && title
Product.where(category:'Comics').all
Product.where(category:'Comics').add_filter(:authors,:contains,'John Smith').all
Product.where(category:'Comics').desc.one
Product.index(:local_index_category_price).add_condition(:category,'Comics')add_condition(:price,:gt,10000).all

保存

新規
product = Product.new(params)
product.save!
更新
product = Product.find(conditions)
product.price += 100
product.update!
product = Product.find(conditions)
product.add(price:100).put(authors:['Andy','Bob','Charlie']).update!

削除

product = Product.find(conditions)
product.add_expected(:price,10000).delete

Contributing

  1. Fork it ( https://github.com/hoshina85/dymos/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

dymos's People

Contributors

crifff avatar k-hoshina avatar

Stargazers

Taras Tadai avatar kaiinui avatar Takuya Hashimoto avatar

Watchers

James Cloos avatar

Forkers

thash

dymos's Issues

バルクのサポート

Dymos.bulk_get(User.where(condition),Article.where(condition)).all
Dymos.bulk_update(User.new(params),User.new(params),User.new(params)...)
みたいな?
一回のリクエストのサイズ上限とかあるのでリトライとかエラーハンドリングどうしよ

クエリの書き方をもうちょっとARに寄せたい

条件検索を Hoge.where(id:1..10).all みたいに書きたい
Hoge.query.index_name(:index_other_id).key_conditions( id: "== hoge", other_id: "between 1 3" )
とか覚えられる気がしないので Hoge.where(id:'hoge',other_id:'between 1 3').index(:index_fuga).allぐらい。仕様インデックスはある程度類推可能な気がする

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.