Permalink
Browse files

override resource_naming_convention to underscore, but not pluralize.…

… I think this is a better fit for what we want in the type field (since it will be per record and not per table)
  • Loading branch information...
1 parent af10553 commit e0833e918e3084fca1bfa59a78def916de3499a0 Wesley Beary committed Jul 21, 2008
@@ -31,6 +31,11 @@ def to_json(dirty = false)
module DataMapper
module Adapters
class CouchDBAdapter < AbstractAdapter
+ def initialize(name, uri_or_options)
+ super(name, uri_or_options)
+ @resource_naming_convention = NamingConventions::Underscored
+ end
+
# Returns the name of the CouchDB database.
#
# Raises an exception if the CouchDB database name is invalid.
@@ -22,9 +22,9 @@ class User
property :location, JsonObject
# creates methods for accessing stored/indexed views in the CouchDB database
- view :by_name, { "map" => "function(doc) { if (doc.type == 'users') { emit(doc.name, doc); } }" }
- view :by_age, { "map" => "function(doc) { if (doc.type == 'users') { emit(doc.age, doc); } }" }
- view :count, { "map" => "function(doc) { if (doc.type == 'users') { emit(null, 1); } }",
+ view :by_name, { "map" => "function(doc) { if (doc.type == 'user') { emit(doc.name, doc); } }" }
+ view :by_age, { "map" => "function(doc) { if (doc.type == 'user') { emit(doc.age, doc); } }" }
+ view :count, { "map" => "function(doc) { if (doc.type == 'user') { emit(null, 1); } }",
"reduce" => "function(keys, values) { return sum(values); }" }
before :create do

0 comments on commit e0833e9

Please sign in to comment.