-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSupportedSchemasQueryStrategy.ts
More file actions
57 lines (54 loc) · 1.84 KB
/
Copy pathSupportedSchemasQueryStrategy.ts
File metadata and controls
57 lines (54 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { Kysely } from "kysely";
import { CachingDatabase } from "../../../types/kyselySupabaseCaching.js";
import { QueryStrategy } from "./QueryStrategy.js";
/**
* Strategy for querying supported EAS (Ethereum Attestation Service) schemas.
* Provides a simple query interface for the supported_schemas table.
*
* This strategy extends the base QueryStrategy to provide schema-specific query building.
* It handles basic data retrieval and counting operations without complex joins or filtering.
*
* @template CachingDatabase - The database type containing the supported_schemas table
*/
export class SupportedSchemasQueryStrategy extends QueryStrategy<
CachingDatabase,
"supported_schemas"
> {
protected readonly tableName = "supported_schemas" as const;
/**
* Builds a query to retrieve supported schema data.
* Returns a simple SELECT query that retrieves all columns from the supported_schemas table.
*
* @param db - Kysely database instance
* @returns A query builder for retrieving supported schema data
*
* @example
* ```typescript
* // Basic query to select all supported schemas
* buildDataQuery(db);
* // SELECT * FROM supported_schemas
* ```
*/
buildDataQuery(db: Kysely<CachingDatabase>) {
return db.selectFrom(this.tableName).selectAll();
}
/**
* Builds a query to count supported schemas.
* Returns a simple COUNT query for the supported_schemas table.
*
* @param db - Kysely database instance
* @returns A query builder for counting supported schemas
*
* @example
* ```typescript
* // Count all supported schemas
* buildCountQuery(db);
* // SELECT COUNT(*) as count FROM supported_schemas
* ```
*/
buildCountQuery(db: Kysely<CachingDatabase>) {
return db.selectFrom(this.tableName).select((eb) => {
return eb.fn.countAll().as("count");
});
}
}