Coder Social home page Coder Social logo

sizkin / devguide-examples Goto Github PK

View Code? Open in Web Editor NEW

This project forked from couchbaselabs/devguide-examples

0.0 2.0 0.0 138 KB

Examples for topics in the developer guide

License: Apache License 2.0

Makefile 0.15% C++ 18.47% C 2.65% C# 12.25% Go 12.15% Java 19.01% JavaScript 18.11% PHP 11.21% Python 5.99%

devguide-examples's Introduction

Developer Guide Examples

These examples are intended to be linked to from within the developer guide. They are currently cross-referenced by language.

Each example should be fully self-contained and executable. For languages which have a significant setup, the example may be split into multiple files, but should still be executable. Error handling is optional but should be be at least hinted at.

Basic Connection

This example should show how to connect to a remote Couchbase cluster and bucket

C | Python | Java| .NET | Go | node.js | PHP

SSL Connection

This example shows how to connect using the server's SSL certificate which has already been downloaded locally to the SDK host. The C-based examples will refer to this path when connecting, while the other SDKs will refer to a specific store and possibly have the example divided into installing and using the certificate.

C | Python | Java | .NET | Go | node.js | PHP

Updating/Storing

This example should show how to store an item into a cluster

C | Python | Java | .NET | Go | node.js | PHP

Retrieving

This example should show how to get items out of the cluster

C | Python | Java | .NET | Go | node.js | PHP

Bulk Storing

This example should show how to store items into a cluster using the Bulk API

C | Python | Java | .NET | Go | node.js (N/A) | PHP

Bulk Retrieving

This example should show how to get items out of the cluster using the Bulk API

C | Python | Java | .NET | Go | node.js (N/A) | PHP

Counter

This example should show how to initialize and update a counter

C | Python | Java | .NET | Go | node.js | PHP

Expiry

This example should show how to initialize a document with an Expiry or "ttl" - time to live

C | Python | Java | .NET | Go | node.js | PHP

Query with criteria

This example should show how to perform a simple query against the travel-sample bucket. The query is something like:

query = N1QLQuery('SELECT airportname, city, country FROM `travel-sample` '
                  'WHERE type="airport" AND city="Reno"')

C | Python | Java | .NET | Go | node.js | PHP

Query with placeholders

This example should demonstrate how to use placeholders, and also the advantages they afford, perhaps by abstracting a given query away as a function, and passing a function parameter down as a query parameter.

This example should also demonstrate in a commented section of code how to optimize this query.

C | Python | Java | .NET | Go | node.js | PHP

Query - Ensuring all documents are the latest (scan consistency)

This example should show how the scan_consistency parameter may be enabled for a specific query.

C | Python | Java | .NET | Go | node.js | PHP

Query - Better reuse of queries with adhoc(false) and Prepared Statements

This example should demonstrate best practice when a statement is to be reused heavily. Setting the adhoc N1QL query tuning to false will use Prepared Statements in the background, which is useful in such a case. Note how this works with placeholders (but of course simple statements work too).

C | Python | Java | .NET | Go | node.js

Query - UPDATE and DELETE

Show how these statements can be used to modify existing documents using secondary document attributes. Also show how a single document can be modified via the USE KEYS clause.

C | Python | .NET | Go | node.js

CAS Handling - Using CAS for concurrent mutations

This example will demonstrate concurrent mutations with and without using the CAS value. Without using the CAS value, some modifications may end up getting lost, whereas using the CAS within a proper retry mechanism will ensure that all mutations remain in tact

C | Python | Java | .NET | Go | node.js | PHP

Durability

Shows storing an item with durability requirements, attempting to persist/replicate to the maximum number of nodes available.

Some SDKs provide APIs to determine how many nodes are in the cluster, while some SDKs allow dynamically persisting to the total number of nodes available, while others only allow fixed numbers. More details may be found in the examples.

C | Python | Java | .NET | Go | node.js | PHP

devguide-examples's People

Contributors

avsej avatar branor avatar daschl avatar lucasrangit avatar mnunberg avatar simonbasle avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.