Skip to content

Commit e7ef3a4

Browse files
Update CouchDatabase
1 parent 1e00d73 commit e7ef3a4

File tree

5 files changed

+7
-8
lines changed

5 files changed

+7
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ public class MyDeathStarContext : CouchContext
523523

524524
If you are not using `CouchContext`, you can still use the database slit feature:
525525
```csharp
526-
var rebels = client.GetDatabase<Rebel>("troups", nameof(Rebel));
526+
var rebels = client.GetDatabase<Rebel>("troups", nameof(Rebel)); // Add [JsonObject("troups")] to Rebel
527527
var vehicles = client.GetDatabase<Vehicle>("troups", nameof(Vehicle));
528528
```
529529

src/CouchDB.Driver/CouchClient.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,9 @@ private Task<IFlurlResponse> CreateDatabaseAsync(QueryContext queryContext,
199199
#region CRUD reflection
200200

201201
/// <inheritdoc />
202-
public ICouchDatabase<TSource> GetDatabase<TSource>() where TSource : CouchDocument
202+
public ICouchDatabase<TSource> GetDatabase<TSource>(string? discriminator = null) where TSource : CouchDocument
203203
{
204-
return GetDatabase<TSource>(GetClassName<TSource>());
204+
return GetDatabase<TSource>(GetClassName<TSource>(), discriminator);
205205
}
206206

207207
/// <inheritdoc />
@@ -345,7 +345,7 @@ public async ValueTask DisposeAsync()
345345

346346
protected virtual async Task DisposeAsync(bool disposing)
347347
{
348-
if (disposing && _flurlClient != null)
348+
if (disposing)
349349
{
350350
if (_options.AuthenticationType == AuthenticationType.Cookie && _options.LogOutOnDispose)
351351
{

src/CouchDB.Driver/CouchDatabase.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
using Newtonsoft.Json;
2626
using System.Net;
2727
using CouchDB.Driver.Views;
28-
using Flurl.Http.Configuration;
29-
using Newtonsoft.Json.Serialization;
3028

3129
namespace CouchDB.Driver
3230
{

src/CouchDB.Driver/Extensions/TypeExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ internal static class TypeExtensions
1212
{
1313
public static string GetName(this Type t, CouchOptions options)
1414
{
15-
var jsonObjectAttributes = t.GetCustomAttributes(typeof(JsonObjectAttribute), true);
15+
object[] jsonObjectAttributes = t.GetCustomAttributes(typeof(JsonObjectAttribute), true);
1616
JsonObjectAttribute? jsonObject = jsonObjectAttributes.Length > 0
1717
? jsonObjectAttributes[0] as JsonObjectAttribute
1818
: null;

src/CouchDB.Driver/ICouchClient.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@ Task<ICouchDatabase<TSource>> GetOrCreateDatabaseAsync<TSource>(string database,
6262
/// If EnsureDatabaseExists is configured, it creates the database if it doesn't exists.
6363
/// </summary>
6464
/// <typeparam name="TSource">The type of database documents.</typeparam>
65+
/// <param name="discriminator">Filters documents by the given discriminator.</param>
6566
/// <returns>The instance of the CouchDB database of the given type.</returns>
66-
ICouchDatabase<TSource> GetDatabase<TSource>() where TSource : CouchDocument;
67+
ICouchDatabase<TSource> GetDatabase<TSource>(string? discriminator = null) where TSource : CouchDocument;
6768

6869
/// <summary>
6970
/// Returns an instance of the CouchDB database with the name type <see cref="TSource"/>.

0 commit comments

Comments
 (0)