Skip to content

Commit 9370e6f

Browse files
feat: optional values in queries
1 parent a32ef89 commit 9370e6f

File tree

6 files changed

+10
-12
lines changed

6 files changed

+10
-12
lines changed
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import { ELASTICSEARCH_INDEX_NAME_METADATA } from 'lib/constants'
22

3-
export const RegisterIndex =
4-
(name: string) =>
5-
<T>(constructor: new () => T): new () => T => {
6-
Reflect.defineMetadata(ELASTICSEARCH_INDEX_NAME_METADATA, name, constructor)
3+
export const RegisterIndex = (name: string) => <T>(constructor: new () => T): new () => T => {
4+
Reflect.defineMetadata(ELASTICSEARCH_INDEX_NAME_METADATA, name, constructor)
75

8-
return constructor
9-
}
6+
return constructor
7+
}

src/lib/queries/get-match-phrase-prefix.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export type MatchPhrasePrefixQuery<TDocument extends Document, TKeyword extends
1414

1515
export const getMatchPhrasePrefixQuery = <TDocument extends Document, TKeyword extends Keyword<TDocument> = Keyword<TDocument>>(
1616
field: TKeyword,
17-
query: KeywordType<TDocument, TKeyword>,
17+
query?: KeywordType<TDocument, TKeyword>,
1818
options?: MatchPhrasePrefixQueryOptions
1919
): MatchPhrasePrefixQuery<TDocument, TKeyword> => ({
2020
// eslint-disable-next-line camelcase

src/lib/queries/get-match.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export type MatchQuery<TDocument extends Document, TKeyword extends Keyword<TDoc
1515

1616
export const getMatchQuery = <TDocument extends Document, TKeyword extends Keyword<TDocument> = Keyword<TDocument>>(
1717
field: TKeyword,
18-
query: KeywordType<TDocument, TKeyword>,
18+
query?: KeywordType<TDocument, TKeyword>,
1919
options?: MatchQueryOptions
2020
): MatchQuery<TDocument, TKeyword> => ({
2121
match: { [field]: { query, ...options } } as MatchQueryBody<TDocument, TKeyword>

src/lib/queries/get-term.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export type TermQuery<TDocument extends Document, TKeyword extends Keyword<TDocu
1010

1111
export const getTermQuery = <TDocument extends Document, TKeyword extends Keyword<TDocument> = Keyword<TDocument>>(
1212
field: TKeyword,
13-
value: KeywordType<TDocument, TKeyword>
13+
value?: KeywordType<TDocument, TKeyword>
1414
): TermQuery<TDocument, TKeyword> => ({
1515
term: { [field]: { value } } as TermQueryBody<TDocument, TKeyword>
1616
})

src/lib/queries/get-terms.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export type TermsQuery<TDocument extends Document, TKeyword extends Keyword<TDoc
1212
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1313
export const getTermsQuery = <TDocument extends Document, TKeyword extends Keyword<TDocument> = Keyword<TDocument>>(
1414
field: TKeyword,
15-
values: Array<KeywordType<TDocument, TKeyword>>
15+
values?: Array<KeywordType<TDocument, TKeyword>>
1616
): TermsQuery<TDocument, TKeyword> => ({
1717
terms: { [field]: values } as TermsQueryBody<TDocument, TKeyword>
1818
})

src/lib/utils/get-should-not.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ export type ShouldNotQuery<TDocument extends Document> = ShouldQuery<TDocument>
66
// eslint-disable-next-line camelcase
77
export const getShouldNotQuery = <TDocument extends Document>(
88
// eslint-disable-next-line camelcase
9-
must_not: MustNotQueryBody<TDocument> | Array<MustNotQueryBody<TDocument>>
10-
): ShouldNotQuery<TDocument> => getShouldQuery(getBoolQuery(getMustNotQuery(must_not)))
9+
body: MustNotQueryBody<TDocument> | Array<MustNotQueryBody<TDocument>>
10+
): ShouldNotQuery<TDocument> => getShouldQuery(getBoolQuery(getMustNotQuery(body)))

0 commit comments

Comments
 (0)