Book Image

Couchbase Essentials

Book Image

Couchbase Essentials

Overview of this book

Table of Contents (15 chapters)
Couchbase Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Storing complex types


So far, we've limited our exploration primarily to simple data types such as strings and integers. In a real application, you're more likely to have business objects or other complex types that you will need to store. To Couchbase Server, the values that you store are nothing more than byte arrays. Therefore, the SDKs are able to use their respective language's binary serializer (often called a transcoder) to store any data structures.

Consider an application that stores information on a user profile. In .NET, you might have a data object that looks like this:

public class UserProfile
{
  public string Username { get; set; }
  
  public string Email { get; set; }
}

When you use the .NET client to save an instance of the UserProfile class in Couchbase Server, it will be serialized using .NET's default binary serializer. Couchbase Server, of course, knows nothing about a client platform's serialization format. It will simply store the byte array it received from the client...