=== Summary: 675 files | 7 generated | 484 fresh | 4605 untracked | 4268 adopted | 355 marked | 466 validated-ok | 2+0 stale (sig+body) | 0 skipped | 0 failed | elapsed 11:08:11.442 (40091.44s) ===

This commit is contained in:
julian
2026-06-28 02:50:05 -07:00
parent a19fb90902
commit 586f02a2ca
654 changed files with 5260 additions and 0 deletions
@@ -15,6 +15,7 @@ namespace adas_core.Infrastructure.Repositories;
/// to customize schema setup, seeding, and insertion behavior.
/// </summary>
/// <typeparam name="T">The domain model type persisted in the MongoDB collection.</typeparam>
/// <!-- aidoc:v1 sig=69998d5 -->
public abstract class MongoRepository<T> : IMongoRepository<T>
{
/// <summary>
@@ -33,6 +34,7 @@ public abstract class MongoRepository<T> : IMongoRepository<T>
/// Initializes a new instance of the <see cref="MongoRepository{T}"/> class using the provided database.
/// </summary>
/// <param name="database">The MongoDB database instance used to access collections. Must not be <see langword="null"/>.</param>
/// <!-- aidoc:v1 sig=d790eeb body=2671b37 -->
protected MongoRepository(IMongoDatabase database)
{
Db = database;
@@ -42,6 +44,7 @@ public abstract class MongoRepository<T> : IMongoRepository<T>
/// When implemented in a derived class, returns the name of the MongoDB collection used to store documents of type <typeparamref name="T"/>.
/// </summary>
/// <returns>The MongoDB collection name as a string.</returns>
/// <!-- aidoc:v1 sig=e2b0ea0 -->
public abstract string GetCollectionName();
/// <summary>
@@ -73,6 +76,7 @@ public abstract class MongoRepository<T> : IMongoRepository<T>
/// </summary>
/// <param name="obj">The document of type <typeparamref name="T"/> to insert.</param>
/// <returns>A <see cref="Task"/> representing the asynchronous insert operation.</returns>
/// <!-- aidoc:v1 sig=7489d1f body=3bc7781 -->
public virtual async Task InsertOneAsync(T obj)
{
try
@@ -93,6 +97,7 @@ public abstract class MongoRepository<T> : IMongoRepository<T>
/// <param name="id">The <see cref="ObjectId"/> value of the document's <c>_id</c> field.</param>
/// <param name="obj">The replacement document of type <typeparamref name="T"/>.</param>
/// <returns>A <see cref="Task"/> representing the asynchronous replace/upsert operation.</returns>
/// <!-- aidoc:v1 sig=e9b79ac body=34c3c0c -->
public async Task UpdateOneAsync(ObjectId id, T obj)
{
try
@@ -117,6 +122,7 @@ public abstract class MongoRepository<T> : IMongoRepository<T>
/// A <see cref="Task{T}"/> representing the asynchronous operation.
/// The task result contains the deleted document, or <see langword="null"/> / default if no document matched or an error occurred.
/// </returns>
/// <!-- aidoc:v1 sig=de6ed30 body=36e5c1c -->
public async Task<T?> DeleteAsync(ObjectId id)
{
try
@@ -136,6 +142,7 @@ public abstract class MongoRepository<T> : IMongoRepository<T>
/// derived classes should override this method to define their own indexes.
/// </summary>
/// <returns>A <see cref="Task"/> representing the asynchronous index creation operation.</returns>
/// <!-- aidoc:v1 sig=f76a2b3 body=6805ef5 -->
public virtual Task CreateIndexes()
{
return Task.CompletedTask;
@@ -146,6 +153,7 @@ public abstract class MongoRepository<T> : IMongoRepository<T>
/// derived classes should override this method to provide custom seeding logic.
/// </summary>
/// <returns>A <see cref="Task"/> representing the asynchronous seeding operation.</returns>
/// <!-- aidoc:v1 sig=e4d5f7d body=6805ef5 -->
public virtual Task InsertInitialLoad()
{
return Task.CompletedTask;
@@ -157,6 +165,7 @@ public abstract class MongoRepository<T> : IMongoRepository<T>
/// </summary>
/// <param name="obj">The list of documents of type <typeparamref name="T"/> to insert.</param>
/// <returns>A <see cref="Task"/> representing the asynchronous bulk insert operation.</returns>
/// <!-- aidoc:v1 sig=f63f7ad body=4633ba9 -->
public virtual async Task InsertManyAsync(List<T> obj)
{
try
@@ -178,6 +187,7 @@ public abstract class MongoRepository<T> : IMongoRepository<T>
/// <param name="id">The new <see cref="ObjectId"/> value to assign.</param>
/// <param name="oldId">The existing <see cref="ObjectId"/> value to replace.</param>
/// <returns>A <see cref="Task"/> representing the asynchronous update operation.</returns>
/// <!-- aidoc:v1 sig=2f5f8d3 body=af391c3 -->
protected async Task UpdateManyObjectIdAsync(string nameId, ObjectId id, ObjectId oldId)
{
try
@@ -202,6 +212,7 @@ public abstract class MongoRepository<T> : IMongoRepository<T>
/// A <see cref="Task{T}"/> representing the asynchronous operation.
/// The task result contains the deleted document, or <see langword="null"/> / default if no document matched or an error occurred.
/// </returns>
/// <!-- aidoc:v1 sig=ec974d1 body=36e5c1c -->
protected async Task<T?> DeleteAsync(string id)
{
try
@@ -225,6 +236,7 @@ public abstract class MongoRepository<T> : IMongoRepository<T>
/// <see langword="true"/> if a collection with the given name exists; otherwise, <see langword="false"/>.
/// Returns <see langword="false"/> when an exception is thrown while querying the database.
/// </returns>
/// <!-- aidoc:v1 sig=bc8012c body=ec4a9e5 -->
protected bool CollectionExists(string collectionName)
{
try