incubator-couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pjmorce <pji...@gmail.com>
Subject Efficient way to identify documents
Date Thu, 07 Jun 2012 12:57:29 GMT
Hello,

I am new to noSQL databases and more precisely to couchDB.

I have migrated my PostgreSQL database to couchDB.

Before, in my relational database I had 2 tables: Authors and Books

Now, for each row of these tables, on my couchDB database I have a document:

{ _id = "author_1"

   {
    name = "a"
    age = "b"
   }
}
{ _id = "author_2"

   {
    name = "abc"
    age = "bcd"
   }
}
{ _id = "book_1"

   {
    title = "the x files"
    year = "1994"
   }
}
{ _id = "book_2"

   {
    title = "the jungle book"
    year = "1964"
   }
}
...

For getting all the authors I created the following view:

function(doc) {
    if(doc._id.indexOf('author_') == 0) {
      emit(null, doc);
    }
}

and for getting all the books I created the following view:

function(doc) {
    if(doc._id.indexOf('book_') == 0) {
      emit(null, doc);
    }
}


Is there any more efficient way to do this? I think this solution is not
performant when large amount of documents will be in the database...

Thank you

Regards

--
View this message in context: http://couchdb-development.1959287.n2.nabble.com/Efficient-way-to-identify-documents-tp7580274.html
Sent from the CouchDB Development mailing list archive at Nabble.com.

Mime
View raw message