-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- improve types - update fragments - update query builder utilities
- Loading branch information
1 parent
ca078df
commit 261e62a
Showing
5 changed files
with
22 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,14 @@ | ||
import { type UpdateTableConfig, isNotNull, isNull } from 'drizzle-orm' | ||
import type { | ||
AnySQLiteSelect, | ||
SQLiteColumn, | ||
SQLiteTableWithColumns, | ||
TableConfig | ||
} from 'drizzle-orm/sqlite-core' | ||
import { SQLWrapper, type UpdateTableConfig, isNotNull, isNull } from 'drizzle-orm' | ||
import type { SQLiteColumn, SQLiteTableWithColumns, TableConfig } from 'drizzle-orm/sqlite-core' | ||
|
||
type Table = SQLiteTableWithColumns< | ||
UpdateTableConfig<TableConfig, { columns: { deletedAt: SQLiteColumn } }> | ||
> | ||
type Query = AnySQLiteSelect | Omit<AnySQLiteSelect, 'where'> | ||
type DynamicQuery<Q extends Query> = ReturnType<Q['$dynamic']> | ||
|
||
export function withUnredacted<Q extends Query, T extends Table>(q: Q, t: T): DynamicQuery<Q> { | ||
return q.$dynamic().where(isNull(t.deletedAt)) as ReturnType<Q['$dynamic']> | ||
export function withUnredacted<T extends Table>(t: T, filters: SQLWrapper[]) { | ||
return [...filters, isNull(t.deletedAt)] | ||
} | ||
|
||
export function withRedacted<Q extends Query, T extends Table>(q: Q, t: T): DynamicQuery<Q> { | ||
return q.$dynamic().where(isNotNull(t.deletedAt)) as DynamicQuery<Q> | ||
export function withRedacted<T extends Table>(t: T, filters: SQLWrapper[]) { | ||
return [...filters, isNotNull(t.deletedAt)] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './tags-to-tasks.schema' | ||
export * from './tags.schema' | ||
export * from './tasks.schema' | ||
export * from './type' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import * as schema from './index' | ||
|
||
type TSchema = typeof schema | ||
|
||
// type StitchesSchema = { [P in keyof Schema]: Schema[P] } | ||
|
||
export interface Schema extends TSchema {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters