Created
October 21, 2009 05:22
-
-
Save adrianpike/214893 to your computer and use it in GitHub Desktop.
This file contains 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
# 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