I had a custom class, that defined in Javascript. I created an object based on the class and stored inside JSON database. When I retrieved the object, the prototype becomes object constructor, instead of custom class. I changed it by assign a custom class prototype to the object prototype.
Problem
But inside the object has other key and values/object, each key has its custom class prototype too, but didn't replace it in nested level.
Code
let client = new CustomClient();
neDB.insert(client, (err, record) => {
record.__proto__ = CustomClient.prototype;
console.log('Custom client record', record);
this.ADD_DEVICE_SETTING(record)
})
Custom client record
{
__proto__: CustomClient constructor
object1: {
__proto__: Object constructor
},
object2: {
__proto__: Object constructor
}
}
Expected
{
__proto__: CustomClient constructor
object1: {
__proto__: CustomObject1 constructor
},
object2: {
__proto__: CustomObject2 constructor
}
}
Question
How do I replace all at once without assign one by one?