CouchDB.NET 0.5.1-pre-alpha

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.5.1-pre-alpha
                    
NuGet\Install-Package CouchDB.NET -Version 0.5.1-pre-alpha
                    
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.5.1-pre-alpha" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CouchDB.NET" Version="0.5.1-pre-alpha" />
                    
Directory.Packages.props
<PackageReference Include="CouchDB.NET" />
                    
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 CouchDB.NET --version 0.5.1-pre-alpha
                    
#r "nuget: CouchDB.NET, 0.5.1-pre-alpha"
                    
#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.
#addin nuget:?package=CouchDB.NET&version=0.5.1-pre-alpha&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=CouchDB.NET&version=0.5.1-pre-alpha&prerelease
                    
Install as a Cake Tool

CouchDB.NET

A .NET driver for CouchDB. * Still in development *

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; }
    

Database operations

var allDbs = await client.GetDatabasesNamesAsync();
var info = await client.GetDatabaseInfoAsync("dbName");
var db = client.GetDatabase<House>("dbName");

await client.AddDatabaseAsync("dbName");
await client.RemoveDatabaseAsync("dbName");

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"
}
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.  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. 
.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 (9)

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

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.6.1 22,367 4/30/2024
3.6.0 4,382 3/11/2024
3.4.0 31,660 6/20/2023
3.3.1 77,743 10/26/2022
3.3.0 6,387 10/19/2022
3.2.0 13,308 7/3/2022
3.2.0-Preview4 2,387 6/13/2022 3.2.0-Preview4 is deprecated because it is no longer maintained.
3.2.0-Preview3 1,033 5/16/2022 3.2.0-Preview3 is deprecated because it is no longer maintained.
3.2.0-Preview2 672 4/6/2022 3.2.0-Preview2 is deprecated because it is no longer maintained.
3.2.0-Preview 10,620 3/6/2022 3.2.0-Preview is deprecated because it is no longer maintained.
3.1.1 55,350 10/14/2021
3.1.0 14,270 3/20/2021
3.0.1 1,085 3/10/2021
3.0.0 1,209 3/9/2021
2.1.0 4,813 9/19/2020
2.0.2 1,442 7/18/2020
2.0.0 1,319 7/14/2020
1.2.2 5,518 7/2/2020
1.2.1 8,231 2/25/2020
1.2.0 2,587 1/24/2020
1.1.5 4,685 12/19/2019
1.1.4 2,214 8/19/2019
1.1.3 1,296 6/14/2019
1.1.2 1,134 6/8/2019
1.1.1 1,112 6/2/2019
1.1.0 1,235 5/5/2019
1.0.2 1,244 5/2/2019
1.0.1 1,133 4/27/2019
1.0.1-beta.4 416 4/25/2019
1.0.1-beta.3 399 4/10/2019
1.0.1-beta.2 398 4/3/2019
1.0.0 1,192 3/31/2019
0.6.0-beta 954 3/18/2019
0.5.2-pre-alpha 1,513 7/18/2018
0.5.1-pre-alpha 1,426 7/13/2018

v0.5.*
- added: FindAsync(string id)
-added: FindAsync(params string[] ids)

v0.5.1
- getDatabase<T>(string name) is not async anymore