Search:

Search all manuals
Search this manual
Manual
Couchbase Server マニュアル 2.0
Community Wiki and Resources
Couchbase Server 2.0をダウンロード
Couchbase 開発者ガイド 2.0
クライアントライブラリ
Couchbase Server フォーラム
Additional Resources
Community Wiki
Community Forums
Couchbase SDKs
Parent Section
E リリースノート
Chapter Sections
Chapters

E.7. Release Notes for Couchbase Server 2.0.0 Build #1554 Developer Preview (10 August 2012)

Couchbase Server 2.0.0 build 1530 contains important document behavior changes that may impact your existing applications. Specifically, this and future releases include changes the way document metadata is handled and exposed when working with Views and creating map and reduce functions in Couchbase Server.

In previous releases, the document supplied as the only argument to the map() function included special fields with an additional prefix that provided information such as the data type, flags, expiration and document ID. For example:

{
 "_id" : "contact_475",
 "_rev" : "1-AB9087AD0977F089",
 "_bin" : "...",
 "$flags" : 0,
 "$expiration" : 0,
 "name" : "Fred Bloggs",
}

This representation has been changed so that the submitted document data and structure remain identical to the document stored and returned by the Views system.

The metadata is now supplied as a object and second argument to the map() function. The format of this object is a JSON document with fields for each of the metadata items previously incorporated in the main document. For example:

{
 "id" : "contact_475",
 "rev" : "1-AB9087AD0977F089",
 "flags" : 0,
 "expiration" : 0,
 "type" : "json",
}

The main flags and their contents remain the same. The _bin, $att_reason have been replaced with a single field, type, that indicates the document data type. For documents identified as valid JSON, the field will have the value json. For non-JSON, the value will be base64.

The meta information for sample documents is now displayed separately, within a non-editable portion of the Web Console.

In addition to these changes, the format and information supplied to the map() function has changed.

To access only the document data within your View, you can use the following map():

function(doc) { 
}

To access the document data and document metadata, including document ID and expiration time, use the two-argument format of the function:

function(doc,meta) {
}

For example, to emit only document information from the View based on the following document structure:

{
 "name": "John",
 "e-mail": "john@john.com"
}

Create a view using only the document object:

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

To create a view that explicitly emits the document ID:

function (doc,meta) {
 emit(meta.id,doc.name);
}

In addition, the doc argument now contains a base64 representation of the document data if the document is not JSON. This can identified using the type field of the meta object. The default map() provided within the Administration Web Console is now:

function (doc, meta) {
 if (meta.type == "json") {
 // If the document is JSON, sort by the schema
 var keys = Object.keys(doc);
 emit(["json", keys.length], keys);
 } else {
 emit(["blob"]);
 }
}

This provides an example of how to process and output documents that are valid JSON or binary documents, using the meta argument to identify the document data type.

Existing client libraries continue to work with the new release without modification to the View or document update mechanisms and information.

New Features and Behaviour Changes in 2.0.0 Build #1554

Known Issues in 2.0.0 Build #1554