CouchDB.NET 0.6.0-beta

This is a prerelease version of CouchDB.NET.
There is a newer version of this package available.
See the version list below for details.
dotnet add package CouchDB.NET --version 0.6.0-beta
NuGet\Install-Package CouchDB.NET -Version 0.6.0-beta
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="CouchDB.NET" Version="0.6.0-beta" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CouchDB.NET --version 0.6.0-beta
#r "nuget: CouchDB.NET, 0.6.0-beta"
#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.
// Install CouchDB.NET as a Cake Addin
#addin nuget:?package=CouchDB.NET&version=0.6.0-beta&prerelease

// Install CouchDB.NET as a Cake Tool
#tool nuget:?package=CouchDB.NET&version=0.6.0-beta&prerelease

CouchDB.NET

A .NET Standard driver for CouchDB databases.

** Still in development ** TODO: implement IQueryable!

LINQ-like queries

C# query example:

var houses = await housesDb.Documents
    .Where(h => 
        h.Owner.Name == "Bobby" && 
        (h.Floors.All(f => f.Area < 120) || h.Floors.Any(f => f.Area > 500))
    )
    .OrderByDescending(h => h.Owner.Name)
    .ThenByDescending(h => h.ConstructionDate)
    .Skip(0)
    .Take(50)
    .Select(
        h => h.Owner.Name, 
        h => h.Address,
        h => h.ConstructionDate)
    .UseBookmark("g1AAAABweJzLY...")
    .WithReadQuorum(150)
    .UpdateIndex()
    .FromStable()
    .ToListAsync();

The produced Mango JSON:

{
    "selector":{ 
        "owner.name":"Bobby",
	"$or":[
    	    {"floors":{"$allMatch":{"area":{"$lt":120}}}},
            {"floors":{"$elemMatch":{"area":{"$gt":500}}}}
    	]
    },
    "limit":50,
    "skip":0,
    "sort":[
    	{"owner.name":"desc"},
    	{"construction_date":"desc"}
    ],
    "fields":[
	    "owner.name",
	    "address",
	    "construction_date"
        ],
    "bookmark":"g1AAAABweJzLY...",
    "r":150,
    "update":true,
    "stable":true
}

Getting started

  • Install it from NuGet: https://www.nuget.org/packages/CouchDB.NET
  • Create a client:
    var client = new CouchClient("http://127.0.0.1:5984");
    
  • If authentication needed:
    client.ConfigureAuthentication("myusername", "mypassword");
    
  • Extend CouchEntity in every model class:
    public class House : CouchEntity
    
  • Use the JsonProperty attribute if you need to override default names:
    [JsonProperty("construction_date")]
    public DateTime ConstructionDate { get; set; }
    

Client operations

var allDbs = await client.GetDatabasesNamesAsync();
var tasks = await client.GetActiveTasksAsync();
// CRUD
var db = client.GetDatabase<House>("dbName");
await client.AddDatabaseAsync("dbName");
await client.RemoveDatabaseAsync("dbName");

Database operations

await db.CompactAsync();
await housesDb.NewIndexAsync(...) // Late in the README
var info = await db.GetInfoAsync();

Documents operations

// CRUD
await housesDb.Documents.AddAsync(house);
await housesDb.Documents.UpdateAsync(house);
await housesDb.Documents.RemoveAsync(house);
var house = await housesDb.Documents.FindAsync(houseId);
// Bulk
await housesDb.Documents.AddRangeAsync(houses);
await housesDb.Documents.UpdateRangeAsync(houses);
var houses = await housesDb.Documents.FindAsync(houseId1, houseId2, houseId3);
var houses = await housesDb.Documents.FindAsync(houseIdArray);
// Enebles stats in queries
housesDb.Documents.EnableStats();
var stats = housesDb.Documents.LastExecutionStats;
// Bookmakrs
var bookmark = housesDb.Documents.LastBookmark;
// Find
var allHouses = await housesDb.Documents.ToListAsync();
var bobbysOnes = await housesDb.Documents.Where(h => h.Owner.Name == "Bobby").ToListAsync();

Indexes (WIP)

C# example:

await housesDb.NewIndexAsync(s => 
        s.Descending(h => h.Address)
            .ThenDescending(h => h.ConstructionDate), 
        name: "useless_index",
        designDocumentName: "my_design"
    );

To JSON:

{
    "index":{
        "fields":[
            {"address":"desc"},
            {"construction_date":"desc"}
        ]
    },
    "name":"useless_index",
    "ddoc":"my_design",
    "type":"json"
}

Contributors

Ben Origas for features like SSL certs and multi queryable, plus bug fixes.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (16)

Showing the top 5 NuGet packages that depend on CouchDB.NET:

Package Downloads
CouchDB.NET.DependencyInjection

Dependency injection utilities for CouchDB.NET

M5x.DEC.Infra

Package Description

M5x.Couch

Macula CouchDB Abstraction

ServiceComponents.Infrastructure.CouchDB

Package Description

Furly.Extensions.CouchDb

CouchDB storage abstraction used by Furly and friends

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on CouchDB.NET:

Repository Stars
matteobortolazzo/couchdb-net
EF Core-like CouchDB experience for .NET!
Version Downloads Last updated
3.6.0 512 3/11/2024
3.4.0 13,061 6/20/2023
3.3.1 20,373 10/26/2022
3.3.0 3,515 10/19/2022
3.2.0 9,736 7/3/2022
3.2.0-Preview4 2,267 6/13/2022
3.2.0-Preview3 785 5/16/2022
3.2.0-Preview2 568 4/6/2022
3.2.0-Preview 10,165 3/6/2022
3.1.1 51,608 10/14/2021
3.1.0 13,530 3/20/2021
3.0.1 922 3/10/2021
3.0.0 1,015 3/9/2021
2.1.0 4,545 9/19/2020
2.0.2 1,262 7/18/2020
2.0.0 1,147 7/14/2020
1.2.2 2,122 7/2/2020
1.2.1 5,441 2/25/2020
1.2.0 2,467 1/24/2020
1.1.5 3,263 12/19/2019
1.1.4 1,979 8/19/2019
1.1.3 1,146 6/14/2019
1.1.2 995 6/8/2019
1.1.1 974 6/2/2019
1.1.0 1,106 5/5/2019
1.0.2 1,111 5/2/2019
1.0.1 991 4/27/2019
1.0.1-beta.4 330 4/25/2019
1.0.1-beta.3 312 4/10/2019
1.0.1-beta.2 311 4/3/2019
1.0.0 1,036 3/31/2019
0.6.0-beta 823 3/18/2019
0.5.2-pre-alpha 1,224 7/18/2018
0.5.1-pre-alpha 1,129 7/13/2018

SSL certificates,
Multiple queryable.
Bug fixes.

Thanks Ben Origas!