Skip to content

Instantly share code, notes, and snippets.

@adrianpike
Created October 21, 2009 05:22
Show Gist options
  • Save adrianpike/214893 to your computer and use it in GitHub Desktop.
Save adrianpike/214893 to your computer and use it in GitHub Desktop.
# rip lots from activerecord as well as datamapper
# ruby's duck typed. a k/v store should be duck typed. therefore why the hell do I care to set the ID to be type of integer if it's just gonna get stuffed in memory somewheres?
class User < Thunderbucket::Base
has_many :comments
belongs_to :user_group
attributes :name, :password, :email
# - or -
attributes true # i can set anything that's not a method to anything, not sure if i wanna actually implement this, could be too dangerous
indexed_attributes :name, :email
end
_Basic stuff_
u = User.find(321)
u.name = foobar
u.save
_Conditional Finds_
u = User.find(:conditions => {:name=>'adrian'})
_Associations_
u.comments
u.user_group
- sorting?
- backed by different stores, push as much down to the store as possible but implement all functionality in the store adapter
- atomic increment
store level:
- user['__max_id__'] = 124
- user[123] = {:name=>'adrian'}
- user.indexes.name['adrian'] = 123
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment