Class CouchDbDataProvider
- Namespace
- combit.Reporting.DataProviders
- Assembly
- combit.ListLabel31.CrossPlatform.dll
Provides a data provider for CouchDB databases.
public sealed class CouchDbDataProvider : IDataProvider
- Inheritance
-
CouchDbDataProvider
- Implements
- Inherited Members
Examples
The following example demonstrates how to use the CouchDbDataProvider to export a report to PDF:
// Example 1: Basic connection with authentication
CouchDbDataProvider provider = new CouchDbDataProvider(
"http://mycouchdb.example.com",
"sales_database",
"all_customers",
"5984",
"myusername",
"mypassword",
"mydomain");
// Optional: Configure provider settings
provider.FlattenStructure = true; // Flatten nested JSON objects
provider.ConnectionTimeout = 30; // 30 seconds timeout
// Create a ListLabel reporting engine instance and assign the provider as the data source.
using ListLabel listLabel = new ListLabel();
listLabel.DataSource = provider;
// Configure export settings to generate a PDF.
ExportConfiguration exportConfiguration = new ExportConfiguration(LlExportTarget.Pdf, exportFilePath, projectFilePath);
exportConfiguration.ShowResult = true;
// Export the report to PDF.
listLabel.Export(exportConfiguration);
// Example 2: Connection without authentication (local development)
CouchDbDataProvider localProvider = new CouchDbDataProvider(
"http://localhost",
"myapp",
"by_date");
// Example 3: Using query parameters to filter view results
CouchDbDataProvider filteredProvider = new CouchDbDataProvider(
"http://mycouchdb.example.com",
"orders_database",
"orders_by_status");
// Add query parameters (startkey, endkey, limit, etc.)
filteredProvider.QueryParameters = "?startkey=\"pending\"&endkey=\"shipped\"&limit=100";
// Example 4: Multiple CouchDB providers with namespace prefixes
CouchDbDataProvider salesProvider = new CouchDbDataProvider(
"http://mycouchdb.example.com",
"sales",
"all_sales");
salesProvider.NamespacePrefix = "Sales_";
CouchDbDataProvider inventoryProvider = new CouchDbDataProvider(
"http://mycouchdb.example.com",
"inventory",
"all_products");
inventoryProvider.NamespacePrefix = "Inventory_";
// Combine in a DataProviderCollection
DataProviderCollection collection = new DataProviderCollection();
collection.Add(salesProvider);
collection.Add(inventoryProvider);
// Example 5: Custom port configuration
CouchDbDataProvider customPortProvider = new CouchDbDataProvider(
"http://mycouchdb.example.com",
"analytics",
"monthly_reports",
"8080"); // Custom port
Remarks
The CouchDbDataProvider class implements IDataProvider to enable connectivity to CouchDB, a document-oriented NoSQL database that uses JSON to store data. CouchDB organizes data into databases containing documents, and provides views (predefined queries) to access and aggregate data. This provider connects to a CouchDB server, executes a specified view, and wraps the resulting JSON data using the JsonDataProvider for seamless integration with List & Label reporting. The provider supports authentication via username and password, configurable connection timeouts, and optional structure flattening to simplify nested JSON hierarchies. Query parameters can be passed to views to filter or customize the returned data. The NamespacePrefix property allows multiple CouchDB data providers to coexist in a DataProviderCollection without table name conflicts.
Constructors
CouchDbDataProvider(string, string, string)
Initializes a new instance of the CouchDbDataProvider class.
public CouchDbDataProvider(string serverUrl, string databaseName, string viewName)
Parameters
serverUrlstringThe URL of the CouchDB server.
databaseNamestringThe name of the CouchDB database.
viewNamestringThe name of the view to use.
CouchDbDataProvider(string, string, string, string)
Initializes a new instance of the CouchDbDataProvider class.
public CouchDbDataProvider(string serverUrl, string databaseName, string viewName, string serverPort)
Parameters
serverUrlstringThe URL of the CouchDB server.
databaseNamestringThe name of the CouchDB database.
viewNamestringThe name of the view to use.
serverPortstringThe port of the CouchDB server.
CouchDbDataProvider(string, string, string, string, string, string, string)
Initializes a new instance of the CouchDbDataProvider class.
public CouchDbDataProvider(string serverUrl, string databaseName, string viewName, string serverPort, string username, string password, string domain)
Parameters
serverUrlstringThe URL of the CouchDB server.
databaseNamestringThe name of the CouchDB database.
viewNamestringThe name of the view to use.
serverPortstringThe port of the CouchDB server.
usernamestringThe username for authentication.
passwordstringThe password for authentication.
domainstringThe domain for authentication.
Properties
ConnectionTimeout
Gets or sets the connection timeout (in seconds).
public int ConnectionTimeout { get; set; }
Property Value
Domain
Gets or sets the domain for the CouchDB connection.
public string Domain { get; set; }
Property Value
FlattenStructure
Gets or sets a value indicating whether the JSON structure should be flattened.
public bool FlattenStructure { get; set; }
Property Value
NamespacePrefix
Gets or sets an optional prefix to all table names. This allows multiple CouchDbDataProvider instances with default settings to be included in a DataProviderCollection.
public string NamespacePrefix { get; set; }
Property Value
Password
Gets or sets the password for the CouchDB connection.
public string Password { get; set; }
Property Value
QueryParameters
Gets or sets the query parameters for the view execution.
public string QueryParameters { get; set; }
Property Value
Username
Gets or sets the username for the CouchDB connection.
public string Username { get; set; }