new front end #33
This commit is contained in:
@@ -46,6 +46,7 @@ function processKeys(map, data, partial){
|
||||
}
|
||||
|
||||
if(errors.length !== 0){
|
||||
console.log('errors', errors)
|
||||
throw new ObjectValidateError(errors);
|
||||
return {__errors__: errors};
|
||||
}
|
||||
@@ -62,7 +63,7 @@ function parseFromString(map, data){
|
||||
};
|
||||
|
||||
for(let key of Object.keys(data)){
|
||||
if(map[key] && map[key].type){
|
||||
if(map[key] && map[key].type && data[key]){
|
||||
data[key] = types[map[key].type](data[key]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ function redisPrefix(key){
|
||||
}
|
||||
|
||||
class Table{
|
||||
static redisClient = client;
|
||||
|
||||
constructor(data){
|
||||
for(let key in data){
|
||||
this[key] = data[key];
|
||||
@@ -86,7 +88,6 @@ class Table{
|
||||
// Add a entry to this redis table.
|
||||
try{
|
||||
// Validate the passed data by the keyMap schema.
|
||||
|
||||
data = objValidate.processKeys(this._keyMap, data);
|
||||
|
||||
// Do not allow the caller to overwrite an existing index key,
|
||||
@@ -107,6 +108,7 @@ class Table{
|
||||
|
||||
// Add the values for this entry.
|
||||
for(let key of Object.keys(data)){
|
||||
if(!data[key]) continue;
|
||||
await client.HSET(
|
||||
redisPrefix(`${this.prototype.constructor.name}_${data[this._key]}`),
|
||||
key,
|
||||
|
||||
Reference in New Issue
Block a user