From f23a4c40bb508b024b58a395c132f29826e3a4b2 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Thu, 5 Jan 2023 11:22:35 +0200 Subject: [PATCH] - Implemented `createRecordAuth()` which is to be used for creating authentication records as it has compile-time guarantees about the fields required in a struct for such a procedure --- source/libpb/driver.d | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/source/libpb/driver.d b/source/libpb/driver.d index d3ef9c2..bba480f 100644 --- a/source/libpb/driver.d +++ b/source/libpb/driver.d @@ -139,6 +139,13 @@ public class PocketBase } } + public RecordType createRecordAuth(string, RecordType)(string table, RecordType item) + { + mixin isAuthable!(RecordType); + + return createRecord(table, item, true); + } + /** * Creates a record in the given table * @@ -150,19 +157,6 @@ public class PocketBase */ public RecordType createRecord(string, RecordType)(string table, RecordType item, bool isAuthCollection = false) { - debug(dbg) - { - writeln(item); - writeln("isAuthCollection: ", isAuthCollection); - } - - //TODO: Implement me, this is always getting triggered for some reason, well makes sense - //it is triggered at compile time to check, we should probably make a seperate method `createRecordAuth()` - if(isAuthCollection) - { - // mixin isAuthable!(RecordType); - } - idAbleCheck(item); RecordType recordOut; @@ -641,7 +635,7 @@ unittest p1.name = "Tristaniha"; p1.age = 29; - p1 = pb.createRecord("dummy_auth", p1, true); + p1 = pb.createRecordAuth("dummy_auth", p1); string tokenIn;