[GH-ISSUE #58] Query naming clash in 'One to N Relations' #645

Open
opened 2026-04-17 22:00:58 -06:00 by gitea-mirror · 2 comments
Owner

Originally created by @h4cc on GitHub (Jul 10, 2015).
Original GitHub issue: https://github.com/jo/couchdb-best-practices/issues/58

I implemented 1-n relations and got the following problem.
In the section https://github.com/eHealthAfrica/couchdb-best-practices#one-to-n-relations the example looks like this:

"_id": "artist:tom-waits:album:closing-time",

When using a query to fetch all artists, also the album relations will be fetched:

/_all_docs?startkey="artist:"&endkey="artist:\ufff"

In the section 'N to N Relations', the example does not have that problem because a own namespace friendship: has been used:

"_id": "friendship:person:avery-mcdonalid:with:person:troy-howell",

Would it be better to have a own namespace for the 'One to N Relations' too?

Originally created by @h4cc on GitHub (Jul 10, 2015). Original GitHub issue: https://github.com/jo/couchdb-best-practices/issues/58 I implemented 1-n relations and got the following problem. In the section https://github.com/eHealthAfrica/couchdb-best-practices#one-to-n-relations the example looks like this: > "_id": "artist:tom-waits:album:closing-time", When using a query to fetch all artists, also the album relations will be fetched: > /_all_docs?startkey="artist:"&endkey="artist:\ufff" In the section 'N to N Relations', the example does not have that problem because a own namespace `friendship:` has been used: > "_id": "friendship:person:avery-mcdonalid:with:person:troy-howell", Would it be better to have a own namespace for the 'One to N Relations' too?
Author
Owner

@fer-ri commented on GitHub (Oct 25, 2018):

Any solution for this? or we need to change the structure of _id?

<!-- gh-comment-id:432891841 --> @fer-ri commented on GitHub (Oct 25, 2018): Any solution for this? or we need to change the structure of `_id`?
Author
Owner

@MarcMcIntosh commented on GitHub (Oct 26, 2018):

a colon ":" is \u003A,
in the querry switching \uffff for \u0034 would exclude some characters.
Can \uffff of \uff0 be used as separator tnsead of a colon?
so the _id would look like
"_id": "friendship\ufffperson\ufffavery-mcdonalid\ufffwith\ufffperson\uffftroy-howell"

<!-- gh-comment-id:433538206 --> @MarcMcIntosh commented on GitHub (Oct 26, 2018): a colon ":" is \u003A, in the querry switching \uffff for \u0034 would exclude some characters. Can \uffff of \uff0 be used as separator tnsead of a colon? so the _id would look like "_id": "friendship\ufffperson\ufffavery-mcdonalid\ufffwith\ufffperson\uffftroy-howell"
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/couchdb-best-practices#645
No description provided.