Skip to content

Couchbase

Install

1
npm install @testcontainers/couchbase --save-dev

Examples

These examples use the following libraries:

Choose an image from the container registry and substitute IMAGE.

Execute a query

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
const bucketDefinition = new BucketDefinition("mybucket");
await using container = await new CouchbaseContainer(image).withBucket(bucketDefinition).start();

const cluster = await couchbase.Cluster.connect(container.getConnectionString(), {
  username: container.getUsername(),
  password: container.getPassword(),
});

const bucket = cluster.bucket(bucketDefinition.getName());

const coll = bucket.defaultCollection();
await coll.upsert("testdoc", { foo: "bar" });
const result = await coll.get("testdoc");

expect(result.content).toEqual({ foo: "bar" });

await cluster.close();