MongoDB provider improvements
This commit is contained in:
parent
422203ac36
commit
044caf533f
|
|
@ -3,6 +3,6 @@ namespace Elsa.Persistence.MongoDb.Options
|
|||
public class ElsaMongoDbOptions
|
||||
{
|
||||
public string? ConnectionString { get; set; }
|
||||
public string? Db { get; set; }
|
||||
public string? DatabaseName { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
using System;
|
||||
using Elsa.Models;
|
||||
using Elsa.Persistence.MongoDb.Options;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
|
@ -11,7 +12,11 @@ namespace Elsa.Persistence.MongoDb.Services
|
|||
{
|
||||
var connectionString = options.Value.ConnectionString;
|
||||
var mongoClient = new MongoClient(connectionString);
|
||||
var databaseName = options.Value.Db is not null and not "" ? options.Value.Db : MongoUrl.Create(connectionString).DatabaseName;
|
||||
var databaseName = options.Value.DatabaseName is not null and not "" ? options.Value.DatabaseName : MongoUrl.Create(connectionString).DatabaseName;
|
||||
|
||||
if (databaseName == null)
|
||||
throw new Exception("Please specify a database name, either via the connection string or via the DatabaseName setting.");
|
||||
|
||||
MongoDatabase = mongoClient.GetDatabase(databaseName);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
<ProjectReference Include="..\..\..\dashboards\blazor\ElsaDashboard.Application\ElsaDashboard.Application.csproj" />
|
||||
<ProjectReference Include="..\..\..\dashboards\blazor\ElsaDashboard.Backend\ElsaDashboard.Backend.csproj" />
|
||||
<ProjectReference Include="..\..\..\persistence\Elsa.Persistence.EntityFramework\Elsa.Persistence.EntityFramework.Sqlite\Elsa.Persistence.EntityFramework.Sqlite.csproj" />
|
||||
<ProjectReference Include="..\..\..\persistence\Elsa.Persistence.MongoDb\Elsa.Persistence.MongoDb.csproj" />
|
||||
<ProjectReference Include="..\..\..\persistence\Elsa.Persistence.YesSql\Elsa.Persistence.YesSql.csproj" />
|
||||
<ProjectReference Include="..\..\..\server\Elsa.Server.Api\Elsa.Server.Api.csproj" />
|
||||
<ProjectReference Include="..\ElsaDashboard.Samples.WebAssembly\ElsaDashboard.Samples.WebAssembly.csproj" />
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ using System.Net.Http.Headers;
|
|||
using Elsa;
|
||||
using Elsa.Persistence.EntityFramework.Core.Extensions;
|
||||
using Elsa.Persistence.EntityFramework.Sqlite;
|
||||
using Elsa.Persistence.MongoDb.Extensions;
|
||||
using ElsaDashboard.Backend.Extensions;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
|
|
@ -31,7 +32,8 @@ namespace ElsaDashboard.Samples.Monolith
|
|||
services
|
||||
.AddElsa(options => options
|
||||
//.UseYesSqlPersistence()
|
||||
.UseEntityFrameworkPersistence(ef => ef.UseSqlite())
|
||||
.UseMongoDbPersistence(mongo => mongo.ConnectionString = "mongodb://localhost/elsa")
|
||||
//.UseEntityFrameworkPersistence(ef => ef.UseSqlite())
|
||||
.AddConsoleActivities()
|
||||
.AddHttpActivities(elsaSection.GetSection("Http").Bind)
|
||||
.AddEmailActivities(elsaSection.GetSection("Smtp").Bind)
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ namespace Elsa.Core.IntegrationTests.Autofixture
|
|||
.AddElsa(elsa => {
|
||||
elsa.UseMongoDbPersistence(opts => {
|
||||
opts.ConnectionString = "mongodb://localhost:27017";
|
||||
opts.Db = "IntegrationTests";
|
||||
opts.DatabaseName = "IntegrationTests";
|
||||
});
|
||||
elsa.AddActivity<UserTask>();
|
||||
elsa.AddWorkflow<PersistableWorkflow>();
|
||||
|
|
|
|||
Loading…
Reference in a new issue