mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-11 00:07:55 +00:00
Extract Database to interface
This commit is contained in:
parent
70df9cd893
commit
90ac186183
27 changed files with 76 additions and 54 deletions
|
|
@ -14,7 +14,7 @@ using Serilog;
|
|||
|
||||
namespace PluralKit.Core
|
||||
{
|
||||
public class Database
|
||||
internal class Database: IDatabase
|
||||
{
|
||||
private readonly CoreConfig _config;
|
||||
private readonly ILogger _logger;
|
||||
|
|
@ -64,18 +64,6 @@ namespace PluralKit.Core
|
|||
await conn.OpenAsync();
|
||||
return conn;
|
||||
}
|
||||
|
||||
public async Task Execute(Func<IPKConnection, Task> func)
|
||||
{
|
||||
await using var conn = await Obtain();
|
||||
await func(conn);
|
||||
}
|
||||
|
||||
public async Task<T> Execute<T>(Func<IPKConnection, Task<T>> func)
|
||||
{
|
||||
await using var conn = await Obtain();
|
||||
return await func(conn);
|
||||
}
|
||||
|
||||
private class PassthroughTypeHandler<T>: SqlMapper.TypeHandler<T>
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue