Created
February 22, 2012 12:16
-
-
Save almost/1884579 to your computer and use it in GitHub Desktop.
CouchDB: M2M link via non-primary keys.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I have meetings like this: | |
{ | |
"type": "meeting" | |
"_id": "MEETINGID", | |
"emails": ["[email protected]", "[email protected]"] | |
// Lots of others things | |
} | |
// I have users like this: | |
{ | |
"type": "user", | |
"_id": "USERID", | |
"emails": ["[email protected]", "[email protected]"] | |
} | |
// I need to keep them linked via email. But I can definitely split out the emails into separate documents if that helps. | |
// I need to be able to lookup all users for a meeting and all meetings for a user. I can see lots of ways to lookup meetings by email and users by email, but that's as far as I get. All the solutions I can think of require multi-level map-reduce which wouldn't work with couch. | |
// I'm looking for a view that produces this: | |
{ | |
"key": "MEETING", | |
"document": {/* user */} | |
} | |
// And one that does the inverse: | |
{ | |
"key": "USERID", | |
"document": {/* meeting */} | |
} | |
// Ideas would be very welcome! :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment