added tests for partitioned collections

This commit is contained in:
alexandre-spieser
2017-08-27 17:35:21 +00:00
parent 5817486f10
commit 5caed5b3a9
13 changed files with 360 additions and 180 deletions
+14 -7
View File
@@ -23,13 +23,6 @@ namespace MongoDbGenericRepository.Models
[BsonId]
public Guid Id { get; set; }
/// <summary>
/// The name of the property used for partitioning the collection
/// This will not be inserted into the collection.
/// This partition key will be prepended to the collection name to create a new collection.
/// </summary>
public string PartitionKey { get; set; }
/// <summary>
/// The datetime in UTC at which the document was added.
/// </summary>
@@ -40,4 +33,18 @@ namespace MongoDbGenericRepository.Models
/// </summary>
public int Version { get; set; }
}
public class PartitionedDocument : Document, IPartitionedDocument
{
public PartitionedDocument(string partitionKey)
{
PartitionKey = partitionKey;
}
/// <summary>
/// The name of the property used for partitioning the collection
/// This will not be inserted into the collection.
/// This partition key will be prepended to the collection name to create a new collection.
/// </summary>
public string PartitionKey { get; set; }
}
}
+15 -1
View File
@@ -2,11 +2,25 @@
namespace MongoDbGenericRepository.Models
{
/// <summary>
/// This class represents a basic document that can be stored in MongoDb.
/// Your document must implement this class in order for the MongoDbRepository to handle them.
/// </summary>
public interface IDocument
{
DateTime AddedAtUtc { get; set; }
Guid Id { get; set; }
string PartitionKey { get; set; }
int Version { get; set; }
}
/// <summary>
/// This class represents a document that can be inserted in a collection that can be partitioned.
/// The partition key allows for the creation of different collections having the same document schema.
/// This can be useful if you are planning to build a Software as a Service (SaaS) Platform, or if you want to reduce indexing.
/// You could for example insert Logs in different collections based on the week and year they where created, or their Log category/source.
/// </summary>
public interface IPartitionedDocument : IDocument
{
string PartitionKey { get; set; }
}
}