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/4f30d73e224e45760ecf to your computer and use it in GitHub Desktop.
Save alexandre-mbm/4f30d73e224e45760ecf to your computer and use it in GitHub Desktop.
Example: Friendly + Sinatra
#!/usr/bin/env ruby
require 'json' # gem install json # also: activesupport (~> 2.3.18)
require 'rubygems' # gem install rubygems
require 'sinatra' # gem install sinatra
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
before do
Friendly.create_tables!
Blob.create({
:name => "Mike",
:value => "Social Justice Hacker"
})
end
get '/' do
Blob.first(:name => "Mike").inspect
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment