What is the maximum value for a CouchDB composite key?

I use what seems like a general trick to create a connection view:

// a Customer has many Orders; show them together in one view:
function(doc) {
  if (doc.Type == "customer") {
    emit([doc._id, 0], doc);
  } else if (doc.Type == "order") {
    emit([doc.customer_id, 1], doc);
  }
}

I know that I can use the following query to get one customerand all related Orders:

?startkey=["some_customer_id"]&endkey=["some_customer_id", 2]

But now I have very closely linked my request to the view code. Is there any value that I can put where I put my " 2" to more clearly say: "I want everything to be tied to this client"? I think I saw

?startkey=["some_customer_id"]&endkey=["some_customer_id", {}]

But I'm not sure what {}will definitely sort out after everything else.

Confirm cmlenz for the join method.

Further explanation from the CouchDB page in the mapping :

startkey=["foo"]&endkey=["foo",{}] "foo" , ["foo","bar"] ["foo",["bar","baz"]]. ["foo",{"an":"object"}]

{} , .

+5
5

, , , , : ?startkey=["some_customer_id"]&endkey=["some_customer_id\u0000"]&inclusive_end=false.

+1

.

0 1 , ( , ) a la [doc._id, doc.created_at]. (, ) "", date +%s. , , , , .

customer_id . , key=<customer_id>. , , , ? , , , , , .

, ruby:

customer_records = records.delete_if { |record| record.type == "customer" }

, , , .

+2

CouchDB Erlang. , / , (, , ). CouchDB CouchDB. , , , , , .

CouchDB , JSON, , ECMAScript. JavaScript IEEE 754 . , 64- double - 5e-324 + 1.7976931348623157e + 308.

0
source

It seems to be nice to have a function where endKey can be included rather than exclusive.

0
source

This should do the trick:

?startkey=["some_customer_id"]&endkey=["some_customer_id", "\uFFFF"]

This should include anything that starts with a character less than \ uFFFF (all Unicode characters)

0
source

All Articles