Reformat project into workspaces
This commit is contained in:
1 parent
20bb10114b
commit
c3e2cf5ed3
38 files changed
+4863
-4186
No files matched your search
@@ -0,0 +1,30 @@
|
||||
// structural interface to the test table
|
||||
export interface CatetoryNode {
|
||||
id: number;
|
||||
name: string;
|
||||
path: string; // ltree field
|
||||
}
|
||||
|
||||
export class CategoryRepository {
|
||||
// simulate generating a SQL query targeting child paths
|
||||
generateDescendantsQuery(parentPath: string): { sql: string; values: string[] } {
|
||||
return {
|
||||
sql: 'SELECT id, name, path FROM categories WHERE path <@ $1::ltree',
|
||||
values: [parentPath]
|
||||
};
|
||||
}
|
||||
|
||||
generateWildcardQuery(pattern: string): { sql: string, values: string[] } {
|
||||
// Simulate genrating a SQL query using ltree wildcards
|
||||
return {
|
||||
sql: 'SELECT id, name, path FROM categories WHERE path ~ $1::lquery',
|
||||
values: [pattern]
|
||||
};
|
||||
}
|
||||
|
||||
// helper utility to validate a string as an ltree value
|
||||
isValidLtreePath(path: string): boolean {
|
||||
const ltreeRegex = /^[A-Za-z0-9_]+(\.[A-Za-z0-9_]+)*$/;
|
||||
return ltreeRegex.test(path);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user