init
This commit is contained in:
commit
ded4f4db26
43 changed files with 2052 additions and 0 deletions
22
Catalogger.Backend/Database/Queries/QueryExtensions.cs
Normal file
22
Catalogger.Backend/Database/Queries/QueryExtensions.cs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
using Catalogger.Backend.Database.Models;
|
||||
using Catalogger.Backend.Extensions;
|
||||
using Remora.Rest.Core;
|
||||
|
||||
namespace Catalogger.Backend.Database.Queries;
|
||||
|
||||
public static class QueryExtensions
|
||||
{
|
||||
public static async ValueTask<Guild> GetGuildAsync(this DatabaseContext db, Snowflake id,
|
||||
CancellationToken ct = default) => await db.GetGuildAsync(id.ToUlong(), ct);
|
||||
|
||||
public static async ValueTask<Guild> GetGuildAsync(this DatabaseContext db, Optional<Snowflake> id,
|
||||
CancellationToken ct = default) => await db.GetGuildAsync(id.ToUlong(), ct);
|
||||
|
||||
public static async ValueTask<Guild> GetGuildAsync(this DatabaseContext db, ulong id,
|
||||
CancellationToken ct = default)
|
||||
{
|
||||
var guild = await db.Guilds.FindAsync(id);
|
||||
if (guild == null) throw new Exception("oh");
|
||||
return guild;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue