before deleting Rules
This commit is contained in:
11
CouchDB/CouchDB.csproj
Normal file
11
CouchDB/CouchDB.csproj
Normal file
@@ -0,0 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Results\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
16
CouchDB/CouchDocument.cs
Normal file
16
CouchDB/CouchDocument.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
namespace CouchDB
|
||||
{
|
||||
public class CouchDocument<T>
|
||||
{
|
||||
public readonly string _id;
|
||||
public readonly string type;
|
||||
public readonly T model;
|
||||
|
||||
public CouchDocument(string id, T model)
|
||||
{
|
||||
_id = id;
|
||||
this.model = model;
|
||||
type = nameof(T);
|
||||
}
|
||||
}
|
||||
}
|
||||
27
CouchDB/Selectors/CouchQuery.cs
Normal file
27
CouchDB/Selectors/CouchQuery.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace CouchDB.Selectors
|
||||
{
|
||||
public class CouchQuery
|
||||
{
|
||||
public static CouchQuery Select => new();
|
||||
|
||||
private readonly List<Equals> equals;
|
||||
protected CouchQuery()
|
||||
{
|
||||
equals = new List<Equals>();
|
||||
}
|
||||
|
||||
public CouchQuery WithEqual(string key, string value)
|
||||
{
|
||||
equals.Add(new Equals(key, value));
|
||||
return this;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
var selector = string.Join(",", equals);
|
||||
return $"{{ \"selector\": {selector}";
|
||||
}
|
||||
}
|
||||
}
|
||||
18
CouchDB/Selectors/Equals.cs
Normal file
18
CouchDB/Selectors/Equals.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
namespace CouchDB.Selectors
|
||||
{
|
||||
public class Equals
|
||||
{
|
||||
private readonly string key;
|
||||
private readonly string value;
|
||||
internal Equals(string key, string value)
|
||||
{
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{{ \"{key}\": {{ \"$eq\": {value}}} }}";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user