Skip to Content
Developing with Couchbase Server
book

Developing with Couchbase Server

by MC Brown
February 2013
Intermediate to advanced
88 pages
2h 7m
English
O'Reilly Media, Inc.
Content preview from Developing with Couchbase Server

Chapter 4. Getting Data In and Out

With Couchbase Server installed, and your chosen client library up and running, it is time to start storing and retrieving information into the database. All of the client libraries use the same basic operations, although they may have different function or methods names. Despite the differences that exist between individual client libraries, the basic operations and how and why you use them are the same.

A basic list of the key Create, Retrieve, Update, and Delete (CRUD) operations is shown in Table 4-1.

Table 4-1. Key CRUD operations

OperationDescription
add(id, document [, expiry])Add an item if ID doesn’t already exist
set(id, document [, expiry])Store a document with ID
replace(id, document [, expiry])Update the document for an existing ID
cas(id, document, check [, expiry])Update the document for an existing ID providing the check matches
get(id)Get the specified document
incr(id [, offset])Increment the document value by offset
decr(id [, offset]Decrement the document value by offset
append(id, value)Append the content to the end of the current document
prepend(id, value)Prepend the content to the beginning of the current document
delete(id)Delete the specified document

There are, though, common use cases and sequences with the different operations that can be used to achieve different processes and solutions. Let’s look at some of these in the context of a typical web application.

Basic Interface

To start, let’s look at a basic Ruby script that ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Getting Started with Couchbase Server

Getting Started with Couchbase Server

MC Brown
Pro Couchbase Server, Second Edition

Pro Couchbase Server, Second Edition

David Ostrovsky, Mohammed Haji, Yaniv Rodenski
Couchbase Essentials

Couchbase Essentials

John C Zablocki

Publisher Resources

ISBN: 9781449331153Errata Page