Skip to content

Commit cd5eaca

Browse files
committed
DatabaseClientImpl.cachePath
1 parent 3fae991 commit cd5eaca

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/runtime/stdlib/databaseClient.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,14 @@ class DatabaseClientImpl implements DatabaseClient {
6666
});
6767
}
6868
async sql(strings: readonly string[], ...params: QueryParam[]): Promise<QueryResult> {
69-
const path = `.observable/cache/${await nameHash(this.name)}-${await hash(strings, ...params)}.json`;
69+
const path = await this.cachePath(strings, ...params);
7070
const response = await fetch(path);
7171
if (!response.ok) throw new Error(`failed to fetch: ${path}`);
7272
return await response.json().then(revive);
7373
}
74+
async cachePath(strings: readonly string[], ...params: QueryParam[]): Promise<string> {
75+
return `.observable/cache/${await nameHash(this.name)}-${await hash(strings, ...params)}.json`;
76+
}
7477
}
7578

7679
function revive({rows, schema, date, ...meta}: SerializableQueryResult): QueryResult {
@@ -104,7 +107,6 @@ function asDate(value: string): Date {
104107
return new Date(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}(?::\d{2})?$/.test(value) ? value + "Z" : value);
105108
}
106109

107-
DatabaseClient.hash = hash;
108110
DatabaseClient.revive = revive;
109111
DatabaseClient.prototype = DatabaseClientImpl.prototype; // instanceof
110112
Object.defineProperty(DatabaseClientImpl, "name", {value: "DatabaseClient"}); // prevent mangling

0 commit comments

Comments
 (0)