Skip to content

Instantly share code, notes, and snippets.

@alexandre-mbm
Forked from mikeymckay/friendly sqlite nosql sinatra
Last active August 29, 2015 14:11
Show Gist options
  • Save alexandre-mbm/5cdbaba3e2fd443b4d11 to your computer and use it in GitHub Desktop.
Save alexandre-mbm/5cdbaba3e2fd443b4d11 to your computer and use it in GitHub Desktop.
Example: Friendly
#!/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