This is a talk about Guacamole, an ODM for ArangoDB to be used in Rack-based framework and especially Rails. Dirk gave the talk in London at Skills Matter
13. Why should I use
ArangoDB in favor of
<any other document store>?
With ArangoDB you can perform joins
over your documents similar
to joins in relational databases.
14.
15. • Powerful query language (AQL)
• REST HTTP interface
• Embedded V8 to allow custom REST interfaces (Foxx)
• Mostly-Memory based with configurable disk synchronization
• Support for Transactions
• Native driver for most languages
22. Design Goal
• Support building web applications with Ruby on Rails or
other Rack-based frameworks
• Focus on easy integration in Views and the general
workflow
• Reflect the nature of NoSQL in general and ArangoDB in
particular
25. + Testability is increased
+ Separation of Concern
+ Easier to support database
features like embedded objects
- The average Rails dev is
used to Active Record
- Starting with Data Mapper
requires more effort
31. The Model™ in Guacamole
class Post
include Guacamole::Model
!
attribute :title, String
attribute :body, String
attribute :comments, Array[Comment]
attribute :user, User
end
32. The Collection™ in Guacamole
class PostsCollection
include Guacamole::Collection
!
map do
embeds :comments
references :user
end
end
33. Retrieving Data
# Get a user by email
UsersCollection.by_example(email: 'p.pie@cupcakes.com')
# => #<User:0x007fca7186fc98>
34. With AQL support
# Get a user by name
UsersCollection.by_aql('FILTER user.name == @name',
name: 'Rainbow Dash')
# => #<User:0x007fca7186fc98>
http://docs.arangodb.org/Aql/README.html
Don’t be scared!
36. class SecurePonyCallbacks
include Guacamole::Callbacks
!
# Those will be triggered by the collection
before_create :encrypt_password
!
def encrypt_password
object.encrypted_password = BCrypt::Password.create(object.password)
end
end
40. • Really useful, not only for Rails
• A lot of Gems build on top of Active Model
• A lot of useful features (i.e. Validations)
• Not related to the Active Record pattern
47. class Author
extend ActiveSupport::Autoload
include Guacamole::Model
!
autoload :Book, 'models/book'
!
attribute :name, String
attribute :books, Array[Book]
end
class Book
extend ActiveSupport::Autoload
include Guacamole::Model
!
autoload :Author, 'models/author'
!
attribute :title, String
attribute :author, Author
end
This is not
very Ruby