Skip to content

Commit

Permalink
refactor: revert tags refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
angeloashmore committed May 5, 2021
1 parent 5c9e7ea commit 0240a18
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,27 +191,35 @@ export class Client {
)
}

getByTags = this.getByTag
async getByTag<TDocument extends Document>(
tags: string[],
params?: Partial<BuildQueryURLArgs>,
): Promise<Query<TDocument>>
async getByTag<TDocument extends Document>(
tags: string | string[],
tag: string,
params?: Partial<BuildQueryURLArgs>,
): Promise<Query<TDocument>> {
return await this.get<TDocument>(
appendPredicates(tagsPredicate(tags))(params),
appendPredicates(tagsPredicate(tag))(params),
)
}

getAllByTags = this.getAllByTag
async getAllByTag<TDocument extends Document>(
tag: string,
params?: Partial<BuildQueryURLArgs>,
): Promise<TDocument[]>
async getAllByTag<TDocument extends Document>(
tags: string | string[],
): Promise<TDocument[]> {
return await this.getAll<TDocument>(
appendPredicates(tagsPredicate(tag))(params),
)
}

async getByTags<TDocument extends Document>(
tags: string[],
params?: Partial<BuildQueryURLArgs>,
): Promise<Query<TDocument>> {
return await this.get<TDocument>(
appendPredicates(tagsPredicate(tags))(params),
)
}

async getAllByTags<TDocument extends Document>(
tags: string[],
params?: Partial<BuildQueryURLArgs>,
): Promise<TDocument[]> {
return await this.getAll<TDocument>(
Expand Down Expand Up @@ -315,3 +323,6 @@ export class Client {
}
}
}

const client = createClient('e')
client.getByTag(['test'])

0 comments on commit 0240a18

Please sign in to comment.