Added relations to redis models

This commit is contained in:
2024-08-15 18:49:42 -04:00
parent 9cf9c76c12
commit c1cfa8bb82
2 changed files with 49 additions and 9 deletions
+20
View File
@@ -29,6 +29,22 @@ class QueryHelper{
}
class Table{
static errors = {
ObjectValidateError: objValidate.ObjectValidateError,
EntryNameUsed: ()=>{
let error = new Error('EntryNameUsed');
error.name = 'EntryNameUsed';
error.message = `${this.prototype.constructor.name}:${data[this._key]} already exists`;
error.keys = [{
key: this._key,
message: `${this.prototype.constructor.name}:${data[this._key]} already exists`
}]
error.status = 409;
return error;
}
}
static redisClient = client;
static models = {}
@@ -139,6 +155,10 @@ class Table{
return out;
}
static findall(...args){
return this.listDetail(...args);
}
static async create(data){
// Add a entry to this redis table.
try{