BitBadger.Npgsql.Documents 1.0.0-beta2

.NET 6.0
This is a prerelease version of BitBadger.Npgsql.Documents.
dotnet add package BitBadger.Npgsql.Documents --version 1.0.0-beta2
NuGet\Install-Package BitBadger.Npgsql.Documents -Version 1.0.0-beta2
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="BitBadger.Npgsql.Documents" Version="1.0.0-beta2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BitBadger.Npgsql.Documents --version 1.0.0-beta2
#r "nuget: BitBadger.Npgsql.Documents, 1.0.0-beta2"
#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 BitBadger.Npgsql.Documents as a Cake Addin
#addin nuget:?package=BitBadger.Npgsql.Documents&version=1.0.0-beta2&prerelease

// Install BitBadger.Npgsql.Documents as a Cake Tool
#tool nuget:?package=BitBadger.Npgsql.Documents&version=1.0.0-beta2&prerelease

This package provides a set of functions that provide a document database interface to a data store backed by PostgreSQL. This library is targeted toward C# usage; for F#, see BitBadger.Npgsql.FSharp.Documents.


  • Select, insert, update, save (upsert), delete, count, and check existence of documents, and create tables and indexes for these documents
  • Addresses documents via ID; via equality on any property by using JSON containment queries; or via condition on any property using JSON Path queries
  • Accesses documents as your domain models (<abbr title="Plain Old CLR Objects">POCO</abbr>s)
  • Uses Task-based async for all data access functions
  • Uses building blocks for more complex queries

Getting Started

The main step is to set the data source with which the library will create connections. Construct an NpgsqlDataSource instance, and provide it to the library:

using BitBadger.Npgsql.Documents

// ...
var dataSource = // ....

// ...

By default, the library uses a System.Text.Json-based serializer configured to use the FSharp.SystemTextJson converter (which will have no noticeable effect for C# uses). To provide a different serializer (different options, more converters, etc.), construct it to implement IDocumentSerializer and provide it via Configuration.UseSerializer.


Retrieve all customers:

// parameter is table name
// returns Task<Customer list>
var customers = await Document.All<Customer>("customer");

Select a customer by ID:

// parameters are table name and ID
// returns Task<Customer option>
var customer = await Document.Find.ById<Customer>("customer", "123");

Count customers in Atlanta:

// parameters are table name and object used for JSON containment query
// return Task<int>
var customerCount = await Document.Count.ByContains("customer", new { City = "Atlanta" });

Delete customers in Chicago: (no offense, Second City; just an example...)

// parameters are table name and JSON Path expression
await Document.Delete.ByJsonPath("customer", "$.City ? (@ == \"Chicago\")");

More Information

The project site has full details on how to use this library.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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 is compatible.  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. 
Compatible target framework(s)
Additional computed target framework(s)
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
1.0.0-beta2 59 2/24/2023
1.0.0-beta 60 2/20/2023

Add Custom.scalar functions