-
Notifications
You must be signed in to change notification settings - Fork 4
Closed
Milestone
Description
To automatically update items stored in the database collections, e.g added or removed field(s), a mechanism is need to sync the changes. Possible solution, this.items is proxied array:
const items = new Proxy([], {
get(target, prop, receiver) {
return target[prop];
},
set(obj, prop, value) {
if (!["length"].includes(prop)) {
// apply missing item properties here
// verfiy object item, if verfiy fails, return false
console.log("Add item: %j", value);
//let { error } = schema.validate(value);
//return error ? false : true;
// save update obj in database?
}
obj[prop] = value;
return true;
}
});
//console.log(items)
try {
items.push({
name: "Room #1",
enabled: true
}, {
name: "Room #2",
enabled: true
});
} catch (err) {
console.log("Could not push", err);
}
//console.log(items[0])With this its possible when the components init, add/remove properties.
Need to test how this affects the performance. How could we prevent that the check runs when component.add is called & through the joi.validate process goes. (First idea: check for the timestamp, if timestamps.created - Date.now() in push is smaller then x does nothing, if greather, run) How to not run this validation on every startup?
Metadata
Metadata
Assignees
Labels
No labels