1

I'm learning about CouchDB, and I don't get it: When I create a view, does the view copy the data that's inside the emit function or it only creates a new index based on it?

For example, let's suppose I have a database with documents like this one:

{
    "name": "Bob",
    "age": 30
}

My view would be something like:

function (doc) {
    emit(doc.name, doc.age);
}

Will CouchDB create a copy of every document (the emitted fields) and the view index when the view is executed for the first time? Or will it create only an index?

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
tastydb
  • 542
  • 1
  • 3
  • 13

1 Answers1

1

With that map function, CouchDB will create a B-tree index based on doc.name with value doc.age and also it will store doc._id somewhere there. So it won't duplicate whole doc but will store those fields and perhaps something else in the index data.

Priidik Vaikla
  • 744
  • 4
  • 13