MCPcopy Create free account
hub / github.com/sshwsfc/xadmin / handle_get_list

Function handle_get_list

packages/xadmin-model/src/effects.js:4–18  ·  view source on GitHub ↗
({ model, filter, wheres })

Source from the content-addressed store, hash-verified

2import app, { api } from 'xadmin'
3
4function *handle_get_list({ model, filter, wheres }) {
5 yield put({ type: 'START_LOADING', model, key: `${model.key}.items` })
6 const { store } = app.context
7 const modelState = store.getState().model[model.key]
8
9 try {
10 const { items, total } = yield api(model).query(filter || modelState.filter, wheres || modelState.wheres)
11 yield put({ type: 'GET_ITEMS', model: model, items: items || [], filter, wheres, count: total })
12 } catch(err) {
13 app.error(err)
14 yield put({ type: 'GET_ITEMS', model: model, items: [], filter, wheres, count: 0 })
15 }
16
17 yield put({ type: 'END_LOADING', model, key: `${model.key}.items` })
18}
19
20function *handle_delete_item({ model, item, message }) {
21 yield put({ type: 'START_LOADING', model, key: `${model.key}.delete` })

Callers

nothing calls this directly

Calls 3

apiFunction · 0.90
queryMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected