Forked from mikeymckay/friendly sqlite nosql sinatra
Last active
August 29, 2015 14:11
-
-
Save alexandre-mbm/5cdbaba3e2fd443b4d11 to your computer and use it in GitHub Desktop.
Example: Friendly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'json' # gem install json # also: activesupport (~> 2.3.18) | |
require 'rubygems' # gem install rubygems | |
require 'friendly' # gem install ihoka-friendly | |
Friendly.configure({ | |
:adapter => "sqlite", | |
:database => "database.sqlite3" | |
}) | |
class Blob | |
include Friendly::Document | |
attribute :name, String | |
attribute :value, String | |
indexes :name | |
end | |
Friendly.create_tables! | |
$obj = Blob.new :name => "Mike", :value => "Social Justice Hacker" | |
$obj.save | |
puts Blob.first(:name => "Mike").inspect |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment