You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Rana Bunnni <ra...@yahoo.se> on 2013/09/15 12:07:07 UTC
difficult issue
Hi,
I have really and difficult issue.
in my CouchDB , i have two document: student , course
in a student document , i have the following properties(fields):
first_name: jan
last_name: box
type: student,
course_name: java
and in another document :
i have the following fields:
course_name : java
week: 20
type: course
teacher: Max
local: 4012
in my database , i have many students and each student study one course_name in the different week.
I want make view , that when i search after one student , can i get all the weeks that he has studied for a specified course?
how can i do that ? please
I did it the following : but its not worked:
function(doc) {
if(doc.type === "student"){
var name = doc.firstName; var courseName = doc.course;
if (doc.type === "course" && doc.courseName === courseName){
emit(doc.courseName,doc);
}
}
}
Best regards
Rana
difficult issue
Posted by Jens Rantil <je...@gmail.com>.
Rana and future readers,
This was thread was double posted, which makes it hard for future mailing
list readers to follow the thread. See
https://mail-archives.apache.org/mod_mbox/couchdb-user/201309.mbox/browserfor
the real conversation.
Cheers,
Jens
On Sunday, September 15, 2013, Rana Bunnni wrote:
> Hi,
> I have really and difficult issue.
> in my CouchDB , i have two document: student , course
> in a student document , i have the following properties(fields):
>
> first_name: jan
> last_name: box
> type: student,
> course_name: java
>
> and in another document :
> i have the following fields:
>
> course_name : java
> week: 20
> type: course
> teacher: Max
> local: 4012
>
> in my database , i have many students and each student study one
> course_name in the different week.
> I want make view , that when i search after one student , can i get all
> the weeks that he has studied for a specified course?
> how can i do that ? please
>
> I did it the following : but its not worked:
> function(doc) {
> if(doc.type === "student"){
> var name = doc.firstName; var courseName = doc.course;
>
> if (doc.type === "course" && doc.courseName === courseName){
> emit(doc.courseName,doc);
> }
> }
> }
>
> Best regards
> Rana