Tech being used:
- Node.js
- Nano
- CouchDB
Disclaimer:
I am very new to CouchDB. I am able to query views with Node.js
and Nano
just fine. I am looking for more of a conceptual solution then a syntax solution.
Scenario:
I am building a very basic web app. I am attempting to get a baseball player from the database and place all his data into a player/profile
page.
This player is going to belong to a team. The team has a short name and a long name.
Here are my databases:
{ name: "Derek Jeter", homeTown: "Brooklyn, New York", team_id: 10 } // player
{ shortName: "Yankees", longName: "NY Yankees", team_id: 10 } // team
I am trying to return a JSON
object that looks like this:
{ name: "Derek Jeter", shortName: "Yankees" }
I know that I can include everything into a single database and use the "type"
property to emit()
based on the type, but I really don't want to do that.
Question:
How can I, using Node
and Nano
to query the player for Derek Jeter
and join
the other data from the other database? I know a view doesn't have access anything other then the current document that it resides, but there has to be another way?
I have searched multiple time on Stackoverflow and Google and I haven't found anyone straying away from the "type"
solution.