types: ignore db.ts

This commit is contained in:
xiaoxian521 2021-10-15 14:08:47 +08:00
parent a7c12d93d3
commit 3cd4f340a1

View File

@ -18,6 +18,7 @@ class DB {
new LocalStorage<Data>(`${DB.env.VITE_TITLE}-${DB.env.VITE_VERSION}`) new LocalStorage<Data>(`${DB.env.VITE_TITLE}-${DB.env.VITE_VERSION}`)
); );
this.initialization(); this.initialization();
// @ts-ignore
this.db.chain = chain(this.db.data); this.db.chain = chain(this.db.data);
} }
private initialization() { private initialization() {
@ -42,8 +43,11 @@ class DB {
const currentPath = `${dbName}.${user ? `user.${uuid}` : "public"}${ const currentPath = `${dbName}.${user ? `user.${uuid}` : "public"}${
path ? `.${path}` : "" path ? `.${path}` : ""
}`; }`;
// @ts-ignore
const value = this.db.chain.get(currentPath).value(); const value = this.db.chain.get(currentPath).value();
// @ts-ignore
if (!(value !== undefined && validator(value))) { if (!(value !== undefined && validator(value))) {
// @ts-ignore
this.db.chain.set(currentPath, defaultValue).value(); this.db.chain.set(currentPath, defaultValue).value();
this.db.write(); this.db.write();
} }
@ -61,6 +65,7 @@ class DB {
path, path,
user user
}); });
// @ts-ignore
this.db.chain.set(currentPath, value).value(); this.db.chain.set(currentPath, value).value();
this.db.write(); this.db.write();
} }
@ -77,6 +82,7 @@ class DB {
defaultValue = "", defaultValue = "",
user = false user = false
}): any { }): any {
// @ts-ignore
const values = this.db.chain const values = this.db.chain
.get(this.pathInit({ dbName, path, user, defaultValue })) .get(this.pathInit({ dbName, path, user, defaultValue }))
.value(); .value();