63 lines
3.2 KiB
C#
63 lines
3.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using MongoDbGenericRepository.DataAccess.Base;
|
|
using MongoDbGenericRepository.Models;
|
|
|
|
namespace MongoDbGenericRepository.DataAccess.Create
|
|
{
|
|
/// <summary>
|
|
/// A interface for adding documents to the Database and its Collections.
|
|
/// </summary>
|
|
public interface IMongoDbCreator : IDataAccessBase
|
|
{
|
|
/// <summary>
|
|
/// Asynchronously adds a document to the collection.
|
|
/// Populates the Id and AddedAtUtc fields if necessary.
|
|
/// </summary>
|
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
|
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
|
|
/// <param name="document">The document you want to add.</param>
|
|
/// <param name="cancellationToken">An optional cancellation Token.</param>
|
|
Task AddOneAsync<TDocument, TKey>(TDocument document, CancellationToken cancellationToken = default)
|
|
where TDocument : IDocument<TKey>
|
|
where TKey : IEquatable<TKey>;
|
|
|
|
/// <summary>
|
|
/// Adds a document to the collection.
|
|
/// Populates the Id and AddedAtUtc fields if necessary.
|
|
/// </summary>
|
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
|
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
|
|
/// <param name="document">The document you want to add.</param>
|
|
/// <param name="cancellationToken">An optional cancellation Token.</param>
|
|
void AddOne<TDocument, TKey>(TDocument document, CancellationToken cancellationToken = default)
|
|
where TDocument : IDocument<TKey>
|
|
where TKey : IEquatable<TKey>;
|
|
|
|
/// <summary>
|
|
/// Asynchronously adds a list of documents to the collection.
|
|
/// Populates the Id and AddedAtUtc fields if necessary.
|
|
/// </summary>
|
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
|
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
|
|
/// <param name="documents">The documents you want to add.</param>
|
|
/// <param name="cancellationToken">An optional cancellation Token.</param>
|
|
Task AddManyAsync<TDocument, TKey>(IEnumerable<TDocument> documents, CancellationToken cancellationToken = default)
|
|
where TDocument : IDocument<TKey>
|
|
where TKey : IEquatable<TKey>;
|
|
|
|
/// <summary>
|
|
/// Adds a list of documents to the collection.
|
|
/// Populates the Id and AddedAtUtc fields if necessary.
|
|
/// </summary>
|
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
|
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
|
|
/// <param name="documents">The documents you want to add.</param>
|
|
/// <param name="cancellationToken">An optional cancellation Token.</param>
|
|
void AddMany<TDocument, TKey>(IEnumerable<TDocument> documents, CancellationToken cancellationToken = default)
|
|
where TDocument : IDocument<TKey>
|
|
where TKey : IEquatable<TKey>;
|
|
}
|
|
} |