Skip to content

Commit 304a8dd

Browse files
committed
fix: useFind: Handle refs in the find getter
1 parent 2fd7f27 commit 304a8dd

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/useFind.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import {
33
getServicePrefix,
44
getServiceCapitalization,
55
getQueryInfo,
6-
getItemsFromQueryInfo
6+
getItemsFromQueryInfo,
7+
Params
78
} from './utils'
89
import debounce from 'lodash/debounce'
910

@@ -49,15 +50,17 @@ export default function find(options) {
4950
}
5051

5152
const state = reactive({
53+
// The find getter
5254
[prefix]: computed(() => {
53-
if (params.paginate) {
55+
const getterParams:Params = isRef(params) ? { ...params.value } : { params }
56+
if (getterParams.paginate) {
5457
const serviceState = model.store.state[model.servicePath]
5558
const { defaultSkip, defaultLimit } = serviceState.pagination
56-
const skip = params.query.$skip || defaultSkip
57-
const limit = params.query.$limit || defaultLimit
58-
const pagination = state[PAGINATION][params.qid || state[QID]] || {}
59+
const skip = getterParams.query.$skip || defaultSkip
60+
const limit = getterParams.query.$limit || defaultLimit
61+
const pagination = state[PAGINATION][getterParams.qid || state[QID]] || {}
5962
const response = skip != null && limit != null ? { limit, skip } : {}
60-
const queryInfo = getQueryInfo(params, response)
63+
const queryInfo = getQueryInfo(getterParams, response)
6164
const items = getItemsFromQueryInfo(
6265
pagination,
6366
queryInfo,
@@ -67,7 +70,7 @@ export default function find(options) {
6770
return items
6871
}
6972
} else {
70-
return model.findInStore(params).data
73+
return model.findInStore(getterParams).data
7174
}
7275
}),
7376
[QID]: qid,

0 commit comments

Comments
 (0)