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

Furly.Extensions.CouchDb

CouchDB storage abstraction used by Furly and friends

ServiceComponents.Infrastructure.CouchDB

Package Description

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.1 8,284 4/30/2024
3.6.0 3,505 3/11/2024
3.4.0 23,883 6/20/2023
3.3.1 44,710 10/26/2022
3.3.0 5,031 10/19/2022
3.2.0 11,680 7/3/2022
3.2.0-Preview4 2,329 6/13/2022 3.2.0-Preview4 is deprecated because it is no longer maintained.
3.2.0-Preview3 927 5/16/2022 3.2.0-Preview3 is deprecated because it is no longer maintained.
3.2.0-Preview2 618 4/6/2022 3.2.0-Preview2 is deprecated because it is no longer maintained.
3.2.0-Preview 10,333 3/6/2022 3.2.0-Preview is deprecated because it is no longer maintained.
3.1.1 53,790 10/14/2021
3.1.0 14,025 3/20/2021
3.0.1 988 3/10/2021
3.0.0 1,106 3/9/2021
2.1.0 4,680 9/19/2020
2.0.2 1,342 7/18/2020
2.0.0 1,222 7/14/2020
1.2.2 3,348 7/2/2020
1.2.1 6,880 2/25/2020
1.2.0 2,513 1/24/2020
1.1.5 3,848 12/19/2019
1.1.4 2,107 8/19/2019
1.1.3 1,212 6/14/2019
1.1.2 1,054 6/8/2019
1.1.1 1,031 6/2/2019
1.1.0 1,155 5/5/2019
1.0.2 1,169 5/2/2019
1.0.1 1,032 4/27/2019
1.0.1-beta.4 343 4/25/2019
1.0.1-beta.3 327 4/10/2019
1.0.1-beta.2 325 4/3/2019
1.0.0 1,102 3/31/2019
0.6.0-beta 878 3/18/2019
0.5.2-pre-alpha 1,279 7/18/2018
0.5.1-pre-alpha 1,179 7/13/2018

SSL certificates,
Multiple queryable.
Bug fixes.

Thanks Ben Origas!