Saeed Heidarizarei
Saeed Heidarizarei

Reputation: 8916

CouchDB loop unique `_id` and Console.log that via JavaScript

I Have 3 Records
"_id": "20","_id": "30" and "_id": "40".

How Can I Console.log _id?

I want to Get This Output

    20
    30
    40

Upvotes: 1

Views: 40

Answers (1)

Michal Demjančuk
Michal Demjančuk

Reputation: 39

Found very easy solve of problem :

function(doc) {
  if (doc.user && doc.title) { // This check is important
    emit(doc.user, {id: doc._id});
  }
}

Then query it :

GET /yourdb/_design/app/_view/by_user?key=film42

Upvotes: 2

Related Questions