-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from event-driven-dotnet/use-mongo-dbcontext
Refactor IMongoCollection<MongoSchema> Registration
- Loading branch information
Showing
3 changed files
with
35 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/EventDriven.SchemaRegistry.Mongo/MongoSchemaRegistryDbContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using MongoDB.Driver; | ||
|
||
namespace EventDriven.SchemaRegistry.Mongo | ||
{ | ||
/// <summary> | ||
/// Mongo Schema Registry DbContext | ||
/// </summary> | ||
public class MongoSchemaRegistryDbContext | ||
{ | ||
/// <summary> | ||
/// MongoSchemaRegistryDbContext constructor. | ||
/// </summary> | ||
/// <param name="client">Mongo client.</param> | ||
/// <param name="schemasDatabaseName">Schemas database name.</param> | ||
/// <param name="schemasCollectionName">Schemas collection name.</param> | ||
public MongoSchemaRegistryDbContext(IMongoClient client, | ||
string schemasDatabaseName, string schemasCollectionName) | ||
{ | ||
var database = client.GetDatabase(schemasDatabaseName); | ||
MongoSchemas = database.GetCollection<MongoSchema>(schemasCollectionName); | ||
} | ||
|
||
/// <summary> | ||
/// Mongo schemas collection. | ||
/// </summary> | ||
public IMongoCollection<MongoSchema> MongoSchemas { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters