Skip to content

Commit 0910a43

Browse files
committed
Implement LiteDB methods for graph repository
- Added LabelMethods for managing labels in LiteDB. - Added NodeMethods for managing nodes in LiteDB. - Added TagMethods for managing tags in LiteDB. - Added TenantMethods for managing tenants in LiteDB. - Added UserMethods for managing users in LiteDB. - Added VectorIndexMethods for managing vector indexes in LiteDB. - Added VectorMethods for managing vectors in LiteDB. - Created unit tests for LiteDBGraphRepository to ensure proper functionality and exception handling.
1 parent 8a2ac6e commit 0910a43

15 files changed

Lines changed: 1653 additions & 12 deletions
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System;
2+
using System.IO;
3+
using System.Threading;
4+
using System.Threading.Tasks;
5+
using LiteGraph.GraphRepositories.Interfaces;
6+
7+
namespace WebNet.LiteGraphExtensions.GraphRepositories.Implementations.LiteDB
8+
{
9+
/// <summary>
10+
/// Admin methods for LiteDB.
11+
/// </summary>
12+
public class AdminMethods : IAdminMethods
13+
{
14+
private readonly LiteDBGraphRepository _repo;
15+
16+
public AdminMethods(LiteDBGraphRepository repo)
17+
{
18+
_repo = repo ?? throw new ArgumentNullException(nameof(repo));
19+
}
20+
21+
public Task Backup(string outputFilename, CancellationToken token = default)
22+
{
23+
throw new NotImplementedException("AdminMethods.Backup not yet implemented for LiteDB");
24+
}
25+
}
26+
}
27+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System;
2+
using System.Threading;
3+
using System.Threading.Tasks;
4+
using LiteGraph;
5+
using LiteGraph.GraphRepositories.Interfaces;
6+
7+
namespace WebNet.LiteGraphExtensions.GraphRepositories.Implementations.LiteDB{
8+
/// <summary>
9+
/// Batch methods for LiteDB.
10+
/// </summary>
11+
public class BatchMethods : IBatchMethods
12+
{
13+
private readonly LiteDBGraphRepository _repo;
14+
15+
public BatchMethods(LiteDBGraphRepository repo)
16+
{
17+
_repo = repo ?? throw new ArgumentNullException(nameof(repo));
18+
}
19+
20+
public Task<ExistenceResult> Existence(Guid tenantGuid, Guid graphGuid, ExistenceRequest req, CancellationToken token = default)
21+
{
22+
throw new NotImplementedException("BatchMethods.Existence not yet implemented for LiteDB");
23+
}
24+
}
25+
}
26+
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Runtime.CompilerServices;
4+
using System.Threading;
5+
using System.Threading.Tasks;
6+
using LiteGraph;
7+
using LiteGraph.GraphRepositories.Interfaces;
8+
9+
namespace WebNet.LiteGraphExtensions.GraphRepositories.Implementations.LiteDB{
10+
/// <summary>
11+
/// Credential methods for LiteDB.
12+
/// </summary>
13+
public class CredentialMethods : ICredentialMethods
14+
{
15+
private readonly LiteDBGraphRepository _repo;
16+
17+
public CredentialMethods(LiteDBGraphRepository repo)
18+
{
19+
_repo = repo ?? throw new ArgumentNullException(nameof(repo));
20+
}
21+
22+
public Task<Credential> Create(Credential credential, CancellationToken token = default)
23+
{
24+
throw new NotImplementedException("CredentialMethods.Create not yet implemented for LiteDB");
25+
}
26+
27+
public async IAsyncEnumerable<Credential> ReadAllInTenant(Guid tenantGuid, EnumerationOrderEnum order = EnumerationOrderEnum.CreatedDescending, int skip = 0, [EnumeratorCancellation] CancellationToken token = default)
28+
{ yield break; throw new NotImplementedException("CredentialMethods.ReadAllInTenant not yet implemented for LiteDB");
29+
}
30+
31+
public async IAsyncEnumerable<Credential> ReadMany(Guid? tenantGuid, Guid? userGuid, string bearerToken, EnumerationOrderEnum order = EnumerationOrderEnum.CreatedDescending, int skip = 0, [EnumeratorCancellation] CancellationToken token = default)
32+
{ yield break; throw new NotImplementedException("CredentialMethods.ReadMany not yet implemented for LiteDB");
33+
}
34+
35+
public Task<Credential> ReadByGuid(Guid tenantGuid, Guid guid, CancellationToken token = default)
36+
{
37+
throw new NotImplementedException("CredentialMethods.ReadByGuid not yet implemented for LiteDB");
38+
}
39+
40+
public async IAsyncEnumerable<Credential> ReadByGuids(Guid tenantGuid, List<Guid> guids, [EnumeratorCancellation] CancellationToken token = default)
41+
{ yield break; throw new NotImplementedException("CredentialMethods.ReadByGuids not yet implemented for LiteDB");
42+
}
43+
44+
public Task<Credential> ReadByBearerToken(string bearerToken, CancellationToken token = default)
45+
{
46+
throw new NotImplementedException("CredentialMethods.ReadByBearerToken not yet implemented for LiteDB");
47+
}
48+
49+
public Task<EnumerationResult<Credential>> Enumerate(EnumerationRequest query, CancellationToken token = default)
50+
{
51+
throw new NotImplementedException("CredentialMethods.Enumerate not yet implemented for LiteDB");
52+
}
53+
54+
public Task<int> GetRecordCount(Guid? tenantGuid, Guid? userGuid, EnumerationOrderEnum order = EnumerationOrderEnum.CreatedDescending, Guid? markerGuid = null, CancellationToken token = default)
55+
{
56+
throw new NotImplementedException("CredentialMethods.GetRecordCount not yet implemented for LiteDB");
57+
}
58+
59+
public Task<Credential> Update(Credential cred, CancellationToken token = default)
60+
{
61+
throw new NotImplementedException("CredentialMethods.Update not yet implemented for LiteDB");
62+
}
63+
64+
public Task DeleteAllInTenant(Guid tenantGuid, CancellationToken token = default)
65+
{
66+
throw new NotImplementedException("CredentialMethods.DeleteAllInTenant not yet implemented for LiteDB");
67+
}
68+
69+
public Task DeleteByGuid(Guid tenantGuid, Guid guid, CancellationToken token = default)
70+
{
71+
throw new NotImplementedException("CredentialMethods.DeleteByGuid not yet implemented for LiteDB");
72+
}
73+
74+
public Task DeleteByUser(Guid tenantGuid, Guid userGuid, CancellationToken token = default)
75+
{
76+
throw new NotImplementedException("CredentialMethods.DeleteByUser not yet implemented for LiteDB");
77+
}
78+
79+
public Task<bool> ExistsByGuid(Guid tenantGuid, Guid guid, CancellationToken token = default)
80+
{
81+
throw new NotImplementedException("CredentialMethods.ExistsByGuid not yet implemented for LiteDB");
82+
}
83+
}
84+
}
85+
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Collections.Specialized;
4+
using System.Runtime.CompilerServices;
5+
using System.Threading;
6+
using System.Threading.Tasks;
7+
using ExpressionTree;
8+
using LiteGraph;
9+
using LiteGraph.GraphRepositories.Interfaces;
10+
11+
namespace WebNet.LiteGraphExtensions.GraphRepositories.Implementations.LiteDB{
12+
/// <summary>
13+
/// Edge methods for LiteDB.
14+
/// </summary>
15+
public class EdgeMethods : IEdgeMethods
16+
{
17+
private readonly LiteDBGraphRepository _repo;
18+
19+
public EdgeMethods(LiteDBGraphRepository repo)
20+
{
21+
_repo = repo ?? throw new ArgumentNullException(nameof(repo));
22+
}
23+
24+
public Task<Edge> Create(Edge edge, CancellationToken token = default)
25+
{
26+
throw new NotImplementedException("EdgeMethods.Create not yet implemented for LiteDB");
27+
}
28+
29+
public Task<List<Edge>> CreateMany(Guid tenantGuid, Guid graphGuid, List<Edge> edges, CancellationToken token = default)
30+
{
31+
throw new NotImplementedException("EdgeMethods.CreateMany not yet implemented for LiteDB");
32+
}
33+
34+
public IAsyncEnumerable<Edge> ReadAllInTenant(Guid tenantGuid, EnumerationOrderEnum order = EnumerationOrderEnum.CreatedDescending, int skip = 0, CancellationToken token = default)
35+
{
36+
throw new NotImplementedException("EdgeMethods.ReadAllInTenant not yet implemented for LiteDB");
37+
}
38+
39+
public IAsyncEnumerable<Edge> ReadAllInGraph(Guid tenantGuid, Guid graphGuid, EnumerationOrderEnum order = EnumerationOrderEnum.CreatedDescending, int skip = 0, CancellationToken token = default)
40+
{
41+
throw new NotImplementedException("EdgeMethods.ReadAllInGraph not yet implemented for LiteDB");
42+
}
43+
44+
public async IAsyncEnumerable<Edge> ReadMany(Guid tenantGuid, Guid graphGuid, string? name = null, List<string>? labels = null, NameValueCollection? tags = null, Expr? edgeFilter = null, EnumerationOrderEnum order = EnumerationOrderEnum.CreatedDescending, int skip = 0, [EnumeratorCancellation] CancellationToken token = default)
45+
{ yield break; throw new NotImplementedException("EdgeMethods.ReadMany not yet implemented for LiteDB");
46+
}
47+
48+
public Task<Edge> ReadFirst(Guid tenantGuid, Guid graphGuid, string? name = null, List<string>? labels = null, NameValueCollection? tags = null, Expr? edgeFilter = null, EnumerationOrderEnum order = EnumerationOrderEnum.CreatedDescending, CancellationToken token = default)
49+
{
50+
throw new NotImplementedException("EdgeMethods.ReadFirst not yet implemented for LiteDB");
51+
}
52+
53+
public Task<Edge> ReadByGuid(Guid tenantGuid, Guid edgeGuid, CancellationToken token = default)
54+
{
55+
throw new NotImplementedException("EdgeMethods.ReadByGuid not yet implemented for LiteDB");
56+
}
57+
58+
public async IAsyncEnumerable<Edge> ReadByGuids(Guid tenantGuid, List<Guid> guids, [EnumeratorCancellation] CancellationToken token = default)
59+
{ yield break; throw new NotImplementedException("EdgeMethods.ReadByGuids not yet implemented for LiteDB");
60+
}
61+
62+
public async IAsyncEnumerable<Edge> GetEdgesFromNode(Guid tenantGuid, Guid graphGuid, Guid nodeGuid, List<string>? labels = null, NameValueCollection? tags = null, Expr? edgeFilter = null, EnumerationOrderEnum order = EnumerationOrderEnum.CreatedDescending, int skip = 0, [EnumeratorCancellation] CancellationToken token = default)
63+
{ yield break; throw new NotImplementedException("EdgeMethods.GetEdgesFromNode not yet implemented for LiteDB");
64+
}
65+
66+
public async IAsyncEnumerable<Edge> GetEdgesToNode(Guid tenantGuid, Guid graphGuid, Guid nodeGuid, List<string>? labels = null, NameValueCollection? tags = null, Expr? edgeFilter = null, EnumerationOrderEnum order = EnumerationOrderEnum.CreatedDescending, int skip = 0, [EnumeratorCancellation] CancellationToken token = default)
67+
{ yield break; throw new NotImplementedException("EdgeMethods.GetEdgesToNode not yet implemented for LiteDB");
68+
}
69+
70+
public async IAsyncEnumerable<Edge> GetEdgesBetweenNodes(Guid tenantGuid, Guid graphGuid, Guid fromNodeGuid, Guid toNodeGuid, List<string>? labels = null, NameValueCollection? tags = null, Expr? edgeFilter = null, EnumerationOrderEnum order = EnumerationOrderEnum.CreatedDescending, int skip = 0, [EnumeratorCancellation] CancellationToken token = default)
71+
{ yield break; throw new NotImplementedException("EdgeMethods.GetEdgesBetweenNodes not yet implemented for LiteDB");
72+
}
73+
74+
public Task<int> GetRecordCount(Guid? tenantGuid, Guid? graphGuid, List<string>? labels = null, NameValueCollection? tags = null, Expr? filter = null, EnumerationOrderEnum order = EnumerationOrderEnum.CreatedDescending, Guid? markerGuid = null, CancellationToken token = default)
75+
{
76+
throw new NotImplementedException("EdgeMethods.GetRecordCount not yet implemented for LiteDB");
77+
}
78+
79+
public Task<Edge> Update(Edge edge, CancellationToken token = default)
80+
{
81+
throw new NotImplementedException("EdgeMethods.Update not yet implemented for LiteDB");
82+
}
83+
84+
public Task DeleteByGuid(Guid tenantGuid, Guid graphGuid, Guid edgeGuid, CancellationToken token = default)
85+
{
86+
throw new NotImplementedException("EdgeMethods.DeleteByGuid not yet implemented for LiteDB");
87+
}
88+
89+
public Task DeleteAllInTenant(Guid tenantGuid, CancellationToken token = default)
90+
{
91+
throw new NotImplementedException("EdgeMethods.DeleteAllInTenant not yet implemented for LiteDB");
92+
}
93+
94+
public Task DeleteAllInGraph(Guid tenantGuid, Guid graphGuid, CancellationToken token = default)
95+
{
96+
throw new NotImplementedException("EdgeMethods.DeleteAllInGraph not yet implemented for LiteDB");
97+
}
98+
public async IAsyncEnumerable<Edge> ReadNodeEdges(Guid tenantGuid, Guid graphGuid, Guid nodeGuid, List<string>? labels = null, NameValueCollection? tags = null, Expr? edgeFilter = null, EnumerationOrderEnum order = EnumerationOrderEnum.CreatedDescending, int skip = 0, [EnumeratorCancellation] CancellationToken token = default)
99+
{ yield break; throw new NotImplementedException("EdgeMethods.ReadNodeEdges not yet implemented for LiteDB");
100+
}
101+
102+
public async IAsyncEnumerable<Edge> ReadEdgesFromNode(Guid tenantGuid, Guid graphGuid, Guid nodeGuid, List<string>? labels = null, NameValueCollection? tags = null, Expr? edgeFilter = null, EnumerationOrderEnum order = EnumerationOrderEnum.CreatedDescending, int skip = 0, [EnumeratorCancellation] CancellationToken token = default)
103+
{ yield break; throw new NotImplementedException("EdgeMethods.ReadEdgesFromNode not yet implemented for LiteDB");
104+
}
105+
106+
public async IAsyncEnumerable<Edge> ReadEdgesToNode(Guid tenantGuid, Guid graphGuid, Guid nodeGuid, List<string>? labels = null, NameValueCollection? tags = null, Expr? edgeFilter = null, EnumerationOrderEnum order = EnumerationOrderEnum.CreatedDescending, int skip = 0, [EnumeratorCancellation] CancellationToken token = default)
107+
{ yield break; throw new NotImplementedException("EdgeMethods.ReadEdgesToNode not yet implemented for LiteDB");
108+
}
109+
110+
public async IAsyncEnumerable<Edge> ReadEdgesBetweenNodes(Guid tenantGuid, Guid graphGuid, Guid fromNodeGuid, Guid toNodeGuid, List<string>? labels = null, NameValueCollection? tags = null, Expr? edgeFilter = null, EnumerationOrderEnum order = EnumerationOrderEnum.CreatedDescending, int skip = 0, [EnumeratorCancellation] CancellationToken token = default)
111+
{ yield break; throw new NotImplementedException("EdgeMethods.ReadEdgesBetweenNodes not yet implemented for LiteDB");
112+
}
113+
114+
public Task<EnumerationResult<Edge>> Enumerate(EnumerationRequest query, CancellationToken token = default)
115+
{
116+
throw new NotImplementedException("EdgeMethods.Enumerate not yet implemented for LiteDB");
117+
}
118+
119+
public Task DeleteNodeEdges(Guid tenantGuid, Guid graphGuid, Guid nodeGuid, CancellationToken token = default)
120+
{
121+
throw new NotImplementedException("EdgeMethods.DeleteNodeEdges not yet implemented for LiteDB");
122+
}
123+
124+
public Task DeleteNodeEdges(Guid tenantGuid, Guid graphGuid, List<Guid> nodeGuids, CancellationToken token = default)
125+
{
126+
throw new NotImplementedException("EdgeMethods.DeleteNodeEdges (multiple nodes) not yet implemented for LiteDB");
127+
}
128+
129+
public Task DeleteMany(Guid tenantGuid, Guid graphGuid, List<Guid> edgeGuids, CancellationToken token = default)
130+
{
131+
throw new NotImplementedException("EdgeMethods.DeleteMany not yet implemented for LiteDB");
132+
}
133+
public Task DeleteByNodeGuid(Guid tenantGuid, Guid graphGuid, Guid nodeGuid, CancellationToken token = default)
134+
{
135+
throw new NotImplementedException("EdgeMethods.DeleteByNodeGuid not yet implemented for LiteDB");
136+
}
137+
138+
public Task<bool> ExistsByGuid(Guid tenantGuid, Guid edgeGuid, CancellationToken token = default)
139+
{
140+
throw new NotImplementedException("EdgeMethods.ExistsByGuid not yet implemented for LiteDB");
141+
}
142+
}
143+
}
144+

0 commit comments

Comments
 (0)