This commit is contained in:
2025-09-16 12:01:06 +02:00
parent 64c7efca5e
commit 5215843308
11 changed files with 202 additions and 151 deletions

View File

@@ -2,10 +2,10 @@ module db
import freeflowuniverse.herolib.data.ourtime
import freeflowuniverse.herolib.data.encoder
import time
pub fn (mut self DB) set[T](mut obj T) ! {
pub fn (mut self DB) set[T](obj_ T) !T {
// Get the next ID
mut obj := obj_
if obj.id == 0 {
obj.id = self.new_id()!
}
@@ -32,6 +32,8 @@ pub fn (mut self DB) set[T](mut obj T) ! {
obj.dump(mut e)!
self.redis.hset(self.db_name[T](), obj.id.str(), e.data.bytestr())!
return obj
}
// return the data, cannot return the object as we do not know the type