Codemancer.Extensions.Couchbase.Lite 0.0.0-beta.11

This is a prerelease version of Codemancer.Extensions.Couchbase.Lite.
There is a newer prerelease version of this package available.
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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Codemancer.Extensions.Couchbase.Lite" Version="0.0.0-beta.11" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Codemancer.Extensions.Couchbase.Lite" Version="0.0.0-beta.11" />
                    
Directory.Packages.props
<PackageReference Include="Codemancer.Extensions.Couchbase.Lite" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Codemancer.Extensions.Couchbase.Lite --version 0.0.0-beta.11
                    
#r "nuget: Codemancer.Extensions.Couchbase.Lite, 0.0.0-beta.11"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Codemancer.Extensions.Couchbase.Lite@0.0.0-beta.11
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Codemancer.Extensions.Couchbase.Lite&version=0.0.0-beta.11&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Codemancer.Extensions.Couchbase.Lite&version=0.0.0-beta.11&prerelease
                    
Install as a Cake Tool

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

  1. 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
  1. 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

  1. 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
  1. 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}");
  1. 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.

  1. Signing Out

To sign out from the Sync Gateway:

    await syncGateway.SignOutAsync();

Note that this terminates the replication service.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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