Skip to content

Commit

Permalink
fix: use optional keys instead of new type
Browse files Browse the repository at this point in the history
  • Loading branch information
harlan-zw committed Jun 3, 2022
1 parent 5549466 commit 5c9f6ca
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/runtime/query/match/pipeline.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { QueryBuilderParams, QueryBuilderSchema, QueryPipe } from '../../types'
import type { QueryBuilderParams, QueryPipe } from '../../types'
import { apply, ensureArray, sortList, withoutKeys, withKeys } from './utils'
import { createMatch } from '.'

Expand All @@ -9,7 +9,7 @@ export function createPipelineFetcher<T> (getContentsList: () => Promise<T[]>) {
/**
* Exctract surrounded items of specific condition
*/
const surround = (data: any[], { query, before, after }: QueryBuilderSchema['surround']) => {
const surround = (data: any[], { query, before, after }: QueryBuilderParams['surround']) => {
const matchQuery = typeof query === 'string' ? { _path: query } : query
// Find matched item index
const index = data.findIndex(item => match(item, matchQuery))
Expand Down
20 changes: 9 additions & 11 deletions src/runtime/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,15 @@ export interface SortFields {

export type SortOptions = SortParams | SortFields

export interface QueryBuilderSchema {
first: boolean
skip: number
limit: number
only: string[]
without: string[]
sort: SortOptions[]
where: object[]
surround: {
export interface QueryBuilderParams {
first?: boolean
skip?: number
limit?: number
only?: string[]
without?: string[]
sort?: SortOptions[]
where?: object[]
surround?: {
query: string | object
before?: number
after?: number
Expand All @@ -170,8 +170,6 @@ export interface QueryBuilderSchema {
[key: string]: any
}

export type QueryBuilderParams = Partial<QueryBuilderSchema>

export interface QueryBuilder<T = ParsedContentMeta> {
/**
* Select a subset of fields
Expand Down

0 comments on commit 5c9f6ca

Please sign in to comment.