Skip to content

Commit 78cd883

Browse files
Merge pull request #522 from hamiltoes/ts/ref-typing
Ts/ref typing
2 parents 1a24b5d + dfb28e0 commit 78cd883

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/service-module/service-module.getters.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ export default function makeServiceGetters() {
8989
if (isRef(id)) {
9090
id = id.value
9191
}
92+
if (isRef(params)) {
93+
params = params.value
94+
}
9295
const record = keyedById[id] && select(params, idField)(keyedById[id])
9396
if (record) {
9497
return record

src/service-module/types.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Service, Id } from '@feathersjs/feathers'
22
import { Params, Paginated } from '../utils'
33
import { EventEmitter } from 'events'
44
import { Store } from 'vuex'
5+
import { Ref } from '@vue/composition-api'
56

67
export { Id } from '@feathersjs/feathers'
78

@@ -244,18 +245,18 @@ export interface ModelStatic extends EventEmitter {
244245
* A proxy for the `find` getter
245246
* @param params Find params
246247
*/
247-
findInStore<M extends Model = Model>(params?: Params): Paginated<M>
248+
findInStore<M extends Model = Model>(params?: Params | Ref<Params>): Paginated<M>
248249

249250
/**
250251
* A proxy for the `count` action
251252
* @param params Find params
252253
*/
253-
count<M extends Model = Model>(params?: Params): Promise<M[] | Paginated<M>>
254+
count(params?: Params): Promise<number>
254255
/**
255256
* A proxy for the `count` getter
256257
* @param params Find params
257258
*/
258-
countInStore<M extends Model = Model>(params?: Params): Paginated<M>
259+
countInStore(params?: Params | Ref<Params>): number
259260

260261
/**
261262
* A proxy for the `get` action
@@ -268,7 +269,7 @@ export interface ModelStatic extends EventEmitter {
268269
* @param id ID of record to retrieve
269270
* @param params Get params
270271
*/
271-
getFromStore<M extends Model = Model>(id: Id, params?: Params): M | undefined
272+
getFromStore<M extends Model = Model>(id: Id | Ref<Id>, params?: Params | Ref<Params>): M | undefined
272273
}
273274

274275
/** Model instance interface */

0 commit comments

Comments
 (0)