- 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

This commit is contained in:
Tristan B. Velloza Kildaire 2023-01-05 11:22:35 +02:00
parent 6a5e1d60ee
commit f23a4c40bb
1 changed files with 8 additions and 14 deletions

View File

@ -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;