Skip to content

Commit

Permalink
feat: chore types
Browse files Browse the repository at this point in the history
  • Loading branch information
Hieuzest committed Jun 14, 2024
1 parent d011fb8 commit 4abd0b2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ export class Database<S = {}, N = {}, C extends Context = Context> extends Servi
async get<K extends Keys<S>, P extends FlatKeys<S[K]> = any>(
table: K,
query: Query<S[K]>,
cursor?: Driver.Cursor<P, S[K], Values<S>>,
cursor?: Driver.Cursor<P, S, K>,
): Promise<FlatPick<S[K], P>[]>

async get<K extends Keys<S>>(table: K, query: Query<S[K]>, cursor?: any) {
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Direction, Modifier, Selection } from './selection.ts'
import { Field, Model, Relation } from './model.ts'
import { Database } from './database.ts'
import { Type } from './type.ts'
import { FlatKeys } from './utils.ts'
import { Keys, Values } from './utils.ts'

export namespace Driver {
export interface Stats {
Expand All @@ -18,14 +18,14 @@ export namespace Driver {
size: number
}

export type Cursor<K extends FlatKeys<T> = any, T = any, S = any> = K[] | CursorOptions<K, T, S>
export type Cursor<K extends string = string, S = any, T extends Keys<S> = any> = K[] | CursorOptions<K, S, T>

export interface CursorOptions<K extends FlatKeys<T> = any, T = any, S = any> {
export interface CursorOptions<K extends string = string, S = any, T extends Keys<S> = any> {
limit?: number
offset?: number
fields?: K[]
sort?: Dict<Direction, K>
include?: Relation.Include<T, S>
include?: Relation.Include<S[T], Values<S>>
}

export interface WriteResult {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ export class Selection<S = any> extends Executable<S, S[]> {
}

execute(): Promise<S[]>
execute<K extends FlatKeys<S> = any>(cursor?: Driver.Cursor<K, S>): Promise<FlatPick<S, K>[]>
execute<K extends FlatKeys<S> = any>(cursor?: Driver.Cursor<K>): Promise<FlatPick<S, K>[]>
execute<T>(callback: Selection.Callback<S, T, true>): Promise<T>
async execute(cursor?: any) {
if (typeof cursor === 'function') {
Expand Down

0 comments on commit 4abd0b2

Please sign in to comment.