Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A small JSON Object Document Mapper.
Ruby
tag: v0.1.0

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec
.gitignore
.rspec
.travis.yml
Gemfile
LICENSE
README.markdown
Rakefile
tyrion.gemspec

README.markdown

Tyrion Build Status

A small JSON ODM.

Goal

Tyrion's goal is to provide a fast (as in easy to setup) and dirty unstructured document store.

Usage

Connection

Tyrion uses a folder to store JSON files, one for each Tyrion document defined. Each file is an array of homogeneous documents (much like collections).

  Tyrion::Connection.path = "/a/folder"

Document

  class Post
    include Tyrion::Document

    field :title
    field :body
    field :rank
  end

Persistence

Save

  post = Post.create :title => "Hello", :body => "Hi there, ..."
  post.save
  # Insta-save with !
  Post.create! :title => "Hello", :body => "Hi there, ..."

Delete

  post = Post.create :title => "Hello", :body => "Hi there, ..."
  post.delete
  Post.delete_all # You get the idea
  Post.where :title => /^Hello/

Querying

find_by_attribute: just the first match

  Post.find_by_title "Hello"
  Post.find_by_body /^Hi there/i

where: all matching documents

  Post.where :title => /^Hello/, :rank => 3
Something went wrong with that request. Please try again.