0.1.1 • Published 7 years ago
@rplan/couchbase v0.1.1
@rplan/couchbase
Introduction
This a simple couchbase wrapper that provides:
- a couchbase bucket configuration through @rplan/config
- a bucket with following methods promisified
getgetMultiupsertinsertreplaceremovequeryping
- implements
findthat behaves like aget, but returns null if key is not found - implements
findMultithat is agetMulti, but returns an error object for each key that is not found - implements
isHealthy, that pings the configured bucket - implements a mocha test-helper
useMockedCouchbaseInTeststhat points the couchbase to acouchbase.Mockinstance during runtime - the following methods are just pass through, because there not async
disconnect
- custom errors
KeyNotFoundErroris thrown on error with code couchbase.errors.keyNotFound - custom errors
KeyAlreadyExistsErroris thrown on error with code couchbase.errors.keyAlreadyExists
Usage
import { bucket } from '@rplan/couchbase'
async function foo() {
await bucket().insert('foo', { bar: true })
const foo = await bucket().get('foo') // { value: { bar: true } }
}Usage of test-helper
import { bucket } from '@rplan/couchbase'
import { useMockedCouchbaseInTests } from '@rplan/couchbase/lib/test-helper'
describe('some test', () => {
useMockedCouchbaseInTests()
it('should work', async () => {
await bucket().insert('a', { foo: 1 })
// ...
})
})