refactor: add SqlKata for SQL generation, move connection handling into ModelRepository
This commit is contained in:
@@ -1,21 +1,16 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Dapper;
|
||||
using SqlKata;
|
||||
|
||||
namespace PluralKit.Core
|
||||
{
|
||||
public partial class ModelRepository
|
||||
{
|
||||
public async Task UpdateAccount(IPKConnection conn, ulong id, AccountPatch patch)
|
||||
public async Task UpdateAccount(ulong id, AccountPatch patch)
|
||||
{
|
||||
_logger.Information("Updated account {accountId}: {@AccountPatch}", id, patch);
|
||||
var (query, pms) = patch.Apply(UpdateQueryBuilder.Update("accounts", "uid = @uid"))
|
||||
.WithConstant("uid", id)
|
||||
.Build();
|
||||
await conn.ExecuteAsync(query, pms);
|
||||
var query = patch.Apply(new Query("accounts").Where("uid", id));
|
||||
await _db.ExecuteQuery(query);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user