Search:

Search all manuals
Search this manual
Manual
Couchbase Server Manual 2.0
Community Wiki and Resources
Download Couchbase Server 2.0
Couchbase Developer Guide 2.0
Client Libraries
Couchbase Server Forum
Additional Resources
Community Wiki
Community Forums
Couchbase SDKs
Parent Section
9.9 View and Query Pattern Samples
Chapter Sections
Chapters

9.9.5. Using Expiration Metadata

The metadata object makes it very easy to create and update different views on your data using information outside of the main document data. For example, you can use the expiration field within a view to get the list of recently active sessions in a system.

Using the following map() function, which uses the expiration as part of the emitted data.

Javascript
function(doc, meta) 
{
  if (doc.type && doc.type == "session") 
  {
    emit(meta.expiration, doc.nickname)
  }
}

If you have sessions which are saved with a TTL, this will allow you to give a view of who was recently active on the service.