@recouch/couchbase-lite-capacitor
v0.2.7
Published
Couchbase Lite bindings for iOS and Android via Capacitor
Downloads
3
Readme
@recouch/couchbase-lite-capacitor
Couchbase Lite bindings for iOS and Android with Capacitor
Install
npm install @recouch/couchbase-lite-capacitor
npx cap sync
API
openDatabase(...)
addDatabaseChangeListener(...)
beginTransaction(...)
closeDatabase(...)
databaseName(...)
databasePath(...)
deleteDatabase(...)
deleteDatabase(...)
endTransaction(...)
removeDatabaseChangeListener(...)
addDocumentChangeListener(...)
deleteDocument(...)
documentExists(...)
getDocument(...)
saveDocument(...)
createQuery(...)
addQueryChangeListener(...)
executeQuery(...)
explainQuery(...)
getQueryParameters(...)
removeQueryChangeListener(...)
setQueryParameters(...)
addDocumentReplicationListener(...)
addReplicatorChangeListener(...)
createReplicator(...)
documentsPendingReplication(...)
isDocumentPendingReplication(...)
removeReplicatorListener(...)
replicatorConfiguration(...)
replicatorStatus(...)
setHostReachable(...)
startReplicator(...)
stopReplicator(...)
blobProperties(...)
databaseGetBlob(...)
databaseSaveBlob(...)
documentGetBlob(...)
documentGetBlobProperties(...)
documentIsBlob(...)
documentSaveBlob(...)
- Interfaces
- Type Aliases
openDatabase(...)
openDatabase(options: { name: string; directory?: string; }) => Result<DatabaseRef>
| Param | Type |
| ------------- | -------------------------------------------------- |
| options
| { name: string; directory?: string; } |
Returns: Result<Tagged<'Database'>>
addDatabaseChangeListener(...)
addDatabaseChangeListener(options: DatabaseRefOptions, handler: DatabaseChangeListener) => Result<ListenerToken>
| Param | Type |
| ------------- | ------------------------------------------------------------------------- |
| options
| DatabaseRefOptions |
| handler
| DatabaseChangeListener |
Returns: Result<Tagged<'ListenerToken'>>
beginTransaction(...)
beginTransaction(options: DatabaseRefOptions) => Result<void>
| Param | Type |
| ------------- | ----------------------------------------------------------------- |
| options
| DatabaseRefOptions |
Returns: Result<void>
closeDatabase(...)
closeDatabase(options: DatabaseRefOptions) => Result<void>
| Param | Type |
| ------------- | ----------------------------------------------------------------- |
| options
| DatabaseRefOptions |
Returns: Result<void>
databaseName(...)
databaseName(options: DatabaseRefOptions) => Result<string>
| Param | Type |
| ------------- | ----------------------------------------------------------------- |
| options
| DatabaseRefOptions |
Returns: Result<string>
databasePath(...)
databasePath(options: DatabaseRefOptions) => Result<string>
| Param | Type |
| ------------- | ----------------------------------------------------------------- |
| options
| DatabaseRefOptions |
Returns: Result<string>
deleteDatabase(...)
deleteDatabase(options: { name: string; directory: string; }) => Result<void>
| Param | Type |
| ------------- | ------------------------------------------------- |
| options
| { name: string; directory: string; } |
Returns: Result<void>
deleteDatabase(...)
deleteDatabase(options: DatabaseRefOptions) => Result<void>
| Param | Type |
| ------------- | ----------------------------------------------------------------- |
| options
| DatabaseRefOptions |
Returns: Result<void>
endTransaction(...)
endTransaction(options: DatabaseRefOptions & { commit: boolean; }) => Result<void>
| Param | Type |
| ------------- | ---------------------------------------------------------------------------------------- |
| options
| DatabaseRefOptions & { commit: boolean; } |
Returns: Result<void>
removeDatabaseChangeListener(...)
removeDatabaseChangeListener(options: { token: ListenerToken; }) => Result<void>
| Param | Type |
| ------------- | --------------------------------------------------------------------------------------------------------- |
| options
| { token: Tagged<'ListenerToken'>; } |
Returns: Result<void>
addDocumentChangeListener(...)
addDocumentChangeListener(options: DatabaseRefOptions & { id: string; }, handler: DocumentChangeListener) => Result<ListenerToken>
| Param | Type |
| ------------- | ----------------------------------------------------------------------------------- |
| options
| DatabaseRefOptions & { id: string; } |
| handler
| DocumentChangeListener |
Returns: Result<Tagged<'ListenerToken'>>
deleteDocument(...)
deleteDocument(options: DatabaseRefOptions & { id: string; }) => Result<void>
| Param | Type |
| ------------- | ----------------------------------------------------------------------------------- |
| options
| DatabaseRefOptions & { id: string; } |
Returns: Result<void>
documentExists(...)
documentExists(options: DatabaseRefOptions & { id: string; }) => Result<boolean>
| Param | Type |
| ------------- | ----------------------------------------------------------------------------------- |
| options
| DatabaseRefOptions & { id: string; } |
Returns: Result<boolean>
getDocument(...)
getDocument<T = object>(options: DatabaseRefOptions & { id: string; }) => Result<T | undefined>
| Param | Type |
| ------------- | ----------------------------------------------------------------------------------- |
| options
| DatabaseRefOptions & { id: string; } |
Returns: Result<T>
saveDocument(...)
saveDocument<T = object>(options: DatabaseRefOptions & { id: string; value: T; }) => Result<void>
| Param | Type |
| ------------- | --------------------------------------------------------------------------------------------- |
| options
| DatabaseRefOptions & { id: string; value: T; } |
Returns: Result<void>
createQuery(...)
createQuery<T = unknown, P = Record<string, string>>(options: DatabaseRefOptions & { query: string; }) => Result<QueryRef<T, P>>
| Param | Type |
| ------------- | -------------------------------------------------------------------------------------- |
| options
| DatabaseRefOptions & { query: string; } |
Returns: Result<QueryRef<T, P>>
addQueryChangeListener(...)
addQueryChangeListener<T = unknown, P = Record<string, string>>(options: QueryRefOptions<T, P>, handler: QueryChangeListener<T>) => Result<ListenerToken>
| Param | Type |
| ------------- | ---------------------------------------------------------------------------- |
| options
| QueryRefOptions<T, P> |
| handler
| QueryChangeListener<T> |
Returns: Result<Tagged<'ListenerToken'>>
executeQuery(...)
executeQuery<T = unknown, P = Record<string, string>>(options: QueryRefOptions<T, P>) => Result<T[]>
| Param | Type |
| ------------- | ----------------------------------------------------------------------- |
| options
| QueryRefOptions<T, P> |
Returns: Result<T[]>
explainQuery(...)
explainQuery<T = unknown, P = Record<string, string>>(options: QueryRefOptions<T, P>) => Result<string>
| Param | Type |
| ------------- | ----------------------------------------------------------------------- |
| options
| QueryRefOptions<T, P> |
Returns: Result<string>
getQueryParameters(...)
getQueryParameters<T = unknown, P = Record<string, string>>(options: QueryRefOptions<T, P>) => Result<Partial<P>>
| Param | Type |
| ------------- | ----------------------------------------------------------------------- |
| options
| QueryRefOptions<T, P> |
Returns: Result<Partial<P>>
removeQueryChangeListener(...)
removeQueryChangeListener(options: { token: ListenerToken; }) => Result<void>
| Param | Type |
| ------------- | --------------------------------------------------------------------------------------------------------- |
| options
| { token: Tagged<'ListenerToken'>; } |
Returns: Result<void>
setQueryParameters(...)
setQueryParameters<T = unknown, P = Record<string, string>>(options: QueryRefOptions<T, P> & { parameters: Partial<P>; }) => Result<void>
| Param | Type |
| ------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| options
| QueryRefOptions<T, P> & { parameters: Partial<P>; } |
Returns: Result<void>
addDocumentReplicationListener(...)
addDocumentReplicationListener(options: ReplicatorRefOptions, handler: DocumentReplicationListener) => Result<ListenerToken>
| Param | Type |
| ------------- | ----------------------------------------------------------------------------------- |
| options
| ReplicatorRefOptions |
| handler
| DocumentReplicationListener |
Returns: Result<Tagged<'ListenerToken'>>
addReplicatorChangeListener(...)
addReplicatorChangeListener(options: ReplicatorRefOptions, handler: ReplicatorChangeListener) => Result<ListenerToken>
| Param | Type |
| ------------- | ----------------------------------------------------------------------------- |
| options
| ReplicatorRefOptions |
| handler
| ReplicatorChangeListener |
Returns: Result<Tagged<'ListenerToken'>>
createReplicator(...)
createReplicator(options: { config: ReplicatorConfiguration; }) => Result<ReplicatorRef>
| Param | Type |
| ------------- | ---------------------------------------------------------------------------------------- |
| options
| { config: ReplicatorConfiguration; } |
Returns: Result<Tagged<'Replicator'>>
documentsPendingReplication(...)
documentsPendingReplication(options: ReplicatorRefOptions) => Result<string[]>
| Param | Type |
| ------------- | --------------------------------------------------------------------- |
| options
| ReplicatorRefOptions |
Returns: Result<string[]>
isDocumentPendingReplication(...)
isDocumentPendingReplication(options: ReplicatorRefOptions & { documentID: string; }) => Result<boolean>
| Param | Type |
| ------------- | ----------------------------------------------------------------------------------------------- |
| options
| ReplicatorRefOptions & { documentID: string; } |
Returns: Result<boolean>
removeReplicatorListener(...)
removeReplicatorListener(options: { token: ListenerToken; }) => Result<void>
| Param | Type |
| ------------- | --------------------------------------------------------------------------------------------------------- |
| options
| { token: Tagged<'ListenerToken'>; } |
Returns: Result<void>
replicatorConfiguration(...)
replicatorConfiguration(options: ReplicatorRefOptions) => Result<ReplicatorConfiguration>
| Param | Type |
| ------------- | --------------------------------------------------------------------- |
| options
| ReplicatorRefOptions |
Returns: Result<ReplicatorConfiguration>
replicatorStatus(...)
replicatorStatus(options: ReplicatorRefOptions) => Result<ReplicatorStatus>
| Param | Type |
| ------------- | --------------------------------------------------------------------- |
| options
| ReplicatorRefOptions |
Returns: Result<ReplicatorStatus>
setHostReachable(...)
setHostReachable(options: ReplicatorRefOptions & { reachable: boolean; }) => Result<void>
| Param | Type |
| ------------- | ----------------------------------------------------------------------------------------------- |
| options
| ReplicatorRefOptions & { reachable: boolean; } |
Returns: Result<void>
startReplicator(...)
startReplicator(options: ReplicatorRefOptions & { resetCheckpoint?: boolean; }) => Result<void>
| Param | Type |
| ------------- | ------------------------------------------------------------------------------------------------------ |
| options
| ReplicatorRefOptions & { resetCheckpoint?: boolean; } |
Returns: Result<void>
stopReplicator(...)
stopReplicator(options: ReplicatorRefOptions) => Result<void>
| Param | Type |
| ------------- | --------------------------------------------------------------------- |
| options
| ReplicatorRefOptions |
Returns: Result<void>
blobProperties(...)
blobProperties(options: BlobOptions) => Result<BlobMetadata>
| Param | Type |
| ------------- | --------------------------------------------------- |
| options
| BlobOptions |
Returns: Result<BlobMetadata>
databaseGetBlob(...)
databaseGetBlob(options: { database: DatabaseRef; properties: BlobMetadata; }) => Result<string>
| Param | Type |
| ------------- | -------------------------------------------------------------------------------------------------------------------------------- |
| options
| { database: Tagged<'Database'>; properties: BlobMetadata; } |
Returns: Result<string>
databaseSaveBlob(...)
databaseSaveBlob(options: BlobOptions & { database: DatabaseRef; }) => Result<void>
| Param | Type |
| ------------- | ------------------------------------------------------------------------------------------------------------------- |
| options
| BlobOptions & { database: Tagged<'Database'>; } |
Returns: Result<void>
documentGetBlob(...)
documentGetBlob(options: DatabaseRefOptions & { id: string; property: string; }) => Result<string>
| Param | Type |
| ------------- | ----------------------------------------------------------------------------------------------------- |
| options
| DatabaseRefOptions & { id: string; property: string; } |
Returns: Result<string>
documentGetBlobProperties(...)
documentGetBlobProperties(options: DatabaseRefOptions & { id: string; property: string; }) => Result<BlobMetadata>
| Param | Type |
| ------------- | ----------------------------------------------------------------------------------------------------- |
| options
| DatabaseRefOptions & { id: string; property: string; } |
Returns: Result<BlobMetadata>
documentIsBlob(...)
documentIsBlob(options: DatabaseRefOptions & { id: string; property: string; }) => Result<boolean>
| Param | Type |
| ------------- | ----------------------------------------------------------------------------------------------------- |
| options
| DatabaseRefOptions & { id: string; property: string; } |
Returns: Result<boolean>
documentSaveBlob(...)
documentSaveBlob(options: DatabaseRefOptions & BlobOptions & { id: string; property: string; }) => Result<void>
| Param | Type |
| ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| options
| DatabaseRefOptions & BlobOptions & { id: string; property: string; } |
Returns: Result<void>
Interfaces
DatabaseRefOptions
| Prop | Type |
| -------------- | --------------------------------------------------- |
| database
| DatabaseRef |
QueryRefOptions
| Prop | Type |
| ----------- | --------------------------------------------------------- |
| query
| QueryRef<T, P> |
ReplicatorRefOptions
| Prop | Type |
| ---------------- | ------------------------------------------------------- |
| replicator
| ReplicatorRef |
ReplicatorStatus
| Prop | Type |
| -------------- | ----------------------------------------------------------------------- |
| activity
| 'stopped' | 'offline' | 'connecting' | 'idle' | 'busy' |
| error
| string |
| progress
| { complete: number; documentCount: number; } |
ReplicatorConfiguration
| Prop | Type |
| ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------- |
| database
| DatabaseRef |
| endpoint
| string | Tagged<'Database'> |
| authenticator
| { type: 'basic'; username: string; password: string; } | { type: 'session'; sessionID: string; cookieName?: string; } |
| replicatorType
| ReplicatorType |
| continuous
| boolean |
| disableAutoPurge
| boolean |
| maxAttempts
| number |
| maxAttemptWaitTime
| number |
| heartbeat
| number |
| conflictResolver
| ((document: { documentID: string; localDocument: object; remoteDocument: object; }) => void) |
| pushFilter
| ((document: { documentID: string; value: object; accessRemoved: boolean; deleted: boolean; }) => void) |
| pullFilter
| ((document: { documentID: string; value: object; accessRemoved: boolean; deleted: boolean; }) => void) |
BlobMetadata
| Prop | Type |
| ------------------ | ------------------- |
| '@type'
| 'blob' |
| content_type
| string |
| digest
| string |
| length
| number |
BlobOptions
| Prop | Type |
| ---------- | ------------------------------------------------- |
| blob
| BlobConfig |
Type Aliases
Result
Promise<T extends void ? void : { value: T }>
DatabaseRef
Opaque<unknown, 'Database'>
Opaque
Create an opaque type, which hides its internal details from the public, and can only be created by being used explicitly.
The generic type parameter can be anything. It doesn't have to be an object.
There have been several discussions about adding this feature to TypeScript via the opaque type
operator, similar to how Flow does it. Unfortunately, nothing has (yet) moved forward:
Type & Tagged<Token>
Tagged
{ readonly [tag]: Token; }
DatabaseChangeListener
(docIDs: string[]): void
ListenerToken
Opaque<unknown, 'ListenerToken'>
DocumentChangeListener
(docID: string): void
QueryRef
Opaque<{ readonly [resultType]: Result; readonly [parametersType]: Parameters; }, 'Query'>
Parameters
Obtain the parameters of a function type in a tuple
T extends (...args: infer P) => any ? P : never
Record
Construct a type with a set of properties K of type T
{ [P in K]: T; }
QueryChangeListener
(results: T[]): void
Partial
Make all properties in T optional
{ [P in keyof T]?: T[P]; }
ReplicatorRef
Opaque<unknown, 'Replicator'>
DocumentReplicationListener
(direction: "push" | "pull", documents: ReplicatedDocInfo[]): void
ReplicatedDocInfo
{ id: string; accessRemoved: boolean; deleted: boolean; error?: string; }
ReplicatorChangeListener
(status: ReplicatorStatus): void
ReplicatorType
'pushAndPull' | 'push' | 'pull'
BlobConfig
{ data: Buffer; contentType?: string; }