Codemancer.Extensions.Couchbase.Lite
0.0.0-beta.11
See the version list below for details.
dotnet add package Codemancer.Extensions.Couchbase.Lite --version 0.0.0-beta.11
NuGet\Install-Package Codemancer.Extensions.Couchbase.Lite -Version 0.0.0-beta.11
<PackageReference Include="Codemancer.Extensions.Couchbase.Lite" Version="0.0.0-beta.11" />
<PackageVersion Include="Codemancer.Extensions.Couchbase.Lite" Version="0.0.0-beta.11" />
<PackageReference Include="Codemancer.Extensions.Couchbase.Lite" />
paket add Codemancer.Extensions.Couchbase.Lite --version 0.0.0-beta.11
#r "nuget: Codemancer.Extensions.Couchbase.Lite, 0.0.0-beta.11"
#:package Codemancer.Extensions.Couchbase.Lite@0.0.0-beta.11
#addin nuget:?package=Codemancer.Extensions.Couchbase.Lite&version=0.0.0-beta.11&prerelease
#tool nuget:?package=Codemancer.Extensions.Couchbase.Lite&version=0.0.0-beta.11&prerelease
Extensions.Couchbase.Lite.Sync
Features
Abstaction over the Couchbase.Lite package database
- Leverages dependency injection to provide a more modern approach to configure a Couchbase.Lite database with associated sync gateway endpoint(s).
- Simplifies the authentication process when connecting to a sync gateway endpoint.
- Provides convenient operations to reconfigure the sync replication settings dynamically.
Getting Started
Prerequisites
- This package is available on NuGet. To install the package you can use the integrated package manager of your IDE, the .NET CLI, or reference the package directly in your project file.
dotnet add package Codemancer.Extensions.Couchbase.Lite
- For data replication features please note that a Couchbase Sync Gateway is required. For a detailed tutorial on setting up a Couchbase Sync Gateway, please refer to the official Couchbase documentation.
Basic Usage
- Configuring a Couchbase.Lite database with a sync gateway endpoint
You can register a Couchbase.Lite database with an associated sync gateway on an IServiceCollection as follows:
services.AddCouchbaseLite("my-database")
.WithSyncGateway(new Uri("wss://{id}.apps.cloud.couchbase.com:4984/{my-endpoint}"), options =>
{
options.ScopeName = "{endpoint-scope}";
options.ConfigureReplication = (username, builder) =>
{
builder.LinkCollection("my-collection", []);
};
});
- AddCouchbaseLite("my-database"): Registers a Couchbase.Lite database named "my-database".
- WithSyncGateway(new Uri("wss://{id}.apps.cloud.couchbase.com:4984/{endpoint-name}"), options ⇒ {...}): Configures the Sync Gateway with a WebSocket URI ...
- options.ScopeName: Sets the scope name associated with the endpoint.
- options.ConfigureReplication: Configures replication settings,
- linking a collection named "my-collection" with an initial channel list
You can resolve an IAppService wherever services are injected via DI. Using the IAppService instance retrieve the configured named ISyncGateway as follows:
IAppService appService = serviceProvider.GetRequiredService<IAppService>();
var syncGateway = appService.GetSyncGateway("{endpoint-name}");
Sync Gateway Authentication
- Create credentials according to the auth provider(s) configured on the sync gatway endpoint.
- Using Anonymous Access
var credentials = Credentials.CreateAnonymous();
- Using Basic Authentication
var credentials = Credentials.CreateBasic("{username}", "{password}");
- Using OpenID Connect (OIDC)
var credentials = Credentials.CreateJwt("{jwt-id-token}");
- Signing In
To sign in to the Sync Gateway using the provided credentials:
await syncGateway.SignInAsync(credentials);
Note that this will automatically kick off the replication service on all configured linked collections.
- Signing Out
To sign out from the Sync Gateway:
await syncGateway.SignOutAsync();
Note that this terminates the replication service.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Couchbase.Lite (>= 3.2.0)
- Microsoft.Extensions.DependencyInjection (>= 8.0.1)
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.1)
- Microsoft.Extensions.Http (>= 8.0.1)
- System.IdentityModel.Tokens.Jwt (>= 8.2.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
0.1.0-beta.23 | 83 | 2/5/2025 |
0.0.0-beta.19 | 69 | 1/22/2025 |
0.0.0-beta.16 | 64 | 1/21/2025 |
0.0.0-beta.11 | 54 | 1/14/2025 |
0.0.0-beta.8 | 51 | 1/14/2025 |