Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
Update how to define views.
I changed my username (this was monki), so needed
to change link to muddle.  Sorry for
inconveniences, I hope it will be more consistent
with my identity in other places moving forward and
at the very least should not change again.
  • Loading branch information
Wesley Beary committed Jan 17, 2009
1 parent 44bc5e2 commit 1893698
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions adapters/dm-couchdb-adapter/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ class User
include DataMapper::Resource

property :name, String
view :by_name_only_this_model, { "map" => "function(doc) { if (doc.couchdb_type == 'User') { emit(doc.name, doc); } }" }
view :by_name_with_descendants, { "map" => "function(doc) { if (#{couchdb_types_condition}) { emit(doc.name, doc); } }" }
view(:by_name_only_this_model) {{ "map" => "function(doc) { if (doc.couchdb_type == 'User') { emit(doc.name, doc); } }" }}
view(:by_name_with_descendants) {{ "map" => "function(doc) { if (#{couchdb_types_condition}) { emit(doc.name, doc); } }" }}
end

couchdb_types_condition builds a condition for you if you want a view that checks to see if the couchdb_type of the record is that of the current model or any of its descendants, just load your models and run Model.couchdb_types_condition and copy/paste the output as the condition in the models view. I will be making this smoother/cleaner, as I need to reimplement view handling.
Expand All @@ -65,4 +65,4 @@ You could then call User.by_name to get a listing of users ordered by name, or p

== Example
For a working example of this functionality checkout muddle, my merb based tumblelog, which uses this adapter to save its posts, at:
http://github.com/monki/muddle
http://github.com/geemus/muddle

0 comments on commit 1893698

Please sign in to comment.