Skip to content

Commit 4108465

Browse files
committed
fix: further implementationerror in mongo DB client
1 parent 3a22b76 commit 4108465

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/db/file/repo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export const createRepo = async (repo: Repo): Promise<Repo> => {
9797
if (err) {
9898
reject(err);
9999
} else {
100-
resolve(doc ? toClass(doc, Repo.prototype) : null);
100+
resolve(toClass(doc, Repo.prototype));
101101
}
102102
});
103103
});

src/db/helper.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
export const toClass = function (obj: any, proto: any) {
2-
obj = JSON.parse(JSON.stringify(obj));
3-
obj.__proto__ = proto;
4-
return obj;
1+
export const toClass = function <T, U>(obj: T, proto: U): U {
2+
const out = JSON.parse(JSON.stringify(obj));
3+
out.__proto__ = proto;
4+
return out as U;
55
};
66

77
export const trimTrailingDotGit = (str: string): string => {

0 commit comments

Comments
 (0)