feat(apiv2): database changes
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@@ -12,7 +13,7 @@ namespace PluralKit.Core
|
||||
{
|
||||
public partial class ModelRepository
|
||||
{
|
||||
public async Task AddSwitch(IPKConnection conn, SystemId system, IReadOnlyCollection<MemberId> members)
|
||||
public async Task<PKSwitch> AddSwitch(IPKConnection conn, SystemId system, IReadOnlyCollection<MemberId> members)
|
||||
{
|
||||
// Use a transaction here since we're doing multiple executed commands in one
|
||||
await using var tx = await conn.BeginTransactionAsync();
|
||||
@@ -38,6 +39,7 @@ namespace PluralKit.Core
|
||||
await tx.CommitAsync();
|
||||
|
||||
_logger.Information("Created {SwitchId} in {SystemId}: {Members}", sw.Id, system, members);
|
||||
return sw;
|
||||
}
|
||||
public async Task EditSwitch(IPKConnection conn, SwitchId switchId, IReadOnlyCollection<MemberId> members)
|
||||
{
|
||||
@@ -95,6 +97,9 @@ namespace PluralKit.Core
|
||||
new { System = system });
|
||||
}
|
||||
|
||||
public Task<PKSwitch> GetSwitchByUuid(IPKConnection conn, Guid uuid) =>
|
||||
conn.QuerySingleOrDefaultAsync<PKSwitch>("select * from switches where uuid = @Uuid", new { Uuid = uuid });
|
||||
|
||||
public async Task<int> GetSwitchCount(IPKConnection conn, SystemId system)
|
||||
{
|
||||
return await conn.QuerySingleAsync<int>("select count(*) from switches where system = @Id", new { Id = system });
|
||||
|
Reference in New Issue
Block a user