8000 [ CRITICAL BUG ] Revert "proxy added" by saracalihan · Pull Request #47 · anchovycation/metronom · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[ CRITICAL BUG ] Revert "proxy added" #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 2 additions & 18 deletions lib/ModelInstance.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Model from './Model';
import { safeWrite, getKeyValue } from './Utilities';
import { safeWrite } from './Utilities';

export interface DataInfo {
redisKey: String,
Expand All @@ -9,7 +9,6 @@ interface ModelFields {
_model: Model;
_previousDataValues: any | Object;
_dataInfo: DataInfo;
_changedValues: any | Object;
}

/**
Expand Down Expand Up @@ -37,20 +36,10 @@ class ModelInstance {
_model: model,
_previousDataValues: data,
_dataInfo: dataInfo,
_changedValues: {},
};
Object.entries(data).forEach(([key, defaultValue]) => {
this[key] = defaultValue;
});
const handler = {
set: (target: Object, key: string, value: any)=>{
this._Model._changedValues[`${key}`] = getKeyValue(key)(target);
target[key as keyof Object] = value;
return true;
}
}
let proxy: any = new Proxy(this, handler);
return proxy;
}

/**
Expand All @@ -59,12 +48,7 @@ class ModelInstance {
public async save(): Promise<void> {
const { _Model, ...data } = this;
const { redisClient, flexSchema, schema } = _Model._model;
const keys = Object.keys(_Model._changedValues);
const tempData: Object = {};
keys.forEach((key) => {
tempData[key as keyof Object] = data[key];
});
await safeWrite(tempData, _Model._dataInfo.redisKey, redisClient, schema, flexSchema);
await safeWrite(data, _Model._dataInfo.redisKey, redisClient, schema, flexSchema);
}

/**
Expand Down
0