Maybe I don't fully understand the question. My database has about 5
different types of documents that can be retrieved any number of ways.
Most of the time a single key lookup is used, but a growing number of
use cases involve multikey lookups.
For example, the character document type looks something like this:
* _id
* name
* realm
* realmclass
* guild
* level
* gear
* version
* crc
Character lookups can be based on an number of things (thank you
document collation!)
* id
* name
* name on realm/realmclass
* name in guild on realm/realmclass
* all in guild on realm/realmclass
* name on realm/realmclass by version
* etc ...
Creating the character view document is pretty simple with the
erlang_couchdb client that I wrote.
ViewData = {obj, [
{"_id", <<"_design/character">>},
{"language", <<"javascript">>},
{"views", {obj, [
{"all", {obj, [
{"map", <<"function(doc) { if (doc.type ==
'character') emit(null, doc) }">>}
]}},
{"by_realm", {obj, [
{"map", <<"function(doc) { if (doc.type ==
'character') emit(doc.realm, doc) }">>}
]}},
{"by_realmclass", {obj, [
{"map", <<"function(doc) { if (doc.type ==
'character') emit([doc.realm, doc.realmclass], doc) }">>}
]}},
{"by_realmguild", {obj, [
{"map", <<"function(doc) { if (doc.type ==
'character') emit([doc.realm, doc.guild], doc) }">>}
]}},
{"by_namerealmclass", {obj, [
{"map", <<"function(doc) { if (doc.type ==
'character') emit([doc.name, doc.realm, doc.realmclass], doc) }">>},
{"reduce", <<"function(_k, v) { var max = undefined;
for(var i=0; i < v.length; i++) { if(!max || v[i].version >
max.version) { max = v[i]; } } return max; }">>}
]}},
...
]}}
]},
couchdb:call(local, {create_document, "iplaywow",
"_design/character", ViewData}).
# Nick Gerakines
On Mon, Jul 28, 2008 at 6:03 PM, Paul Davis <[EMAIL PROTECTED]> wrote:
> Just had a thought, with 20 views, how do you (and anyone else) manage
> to keep that straight?
>
> I've been futzing around with storing design docs in a directory as
> json files and then comparing the md5 of the file to an md5 attribute
> of the doc and overwriting on mismatch.
>
> One thing I rather dislike about the whole situation is that functions
> are hard maintain to because of escaping etc.
>
> On Mon, Jul 28, 2008 at 8:55 PM, Nick Gerakines <[EMAIL PROTECTED]> wrote:
>> Hey, thats me! If anyone has any questions please feel free to ask on
>> list or directly.
>>
>> # Nick Gerakines
>>
>> On Mon, Jul 28, 2008 at 5:29 PM, Gilbert B Garza
>> <[EMAIL PROTECTED]> wrote:
>>> Not my own success story, but one I came across while browsing:
>>>
>>> http://blog.socklabs.com/2008/07/more_on_deploying_couchdb_for/
>>>
>>
>