mirror of
https://github.com/baserow/baserow.git
synced 2026-12-06 01:08:32 +00:00
72 lines
1.5 KiB
JavaScript
72 lines
1.5 KiB
JavaScript
export default (client) => {
|
|
return {
|
|
fetchRows({
|
|
gridId,
|
|
limit = 100,
|
|
offset = null,
|
|
cancelToken = null,
|
|
includeFieldOptions = false,
|
|
includeRowMetadata = true,
|
|
search = false,
|
|
}) {
|
|
const config = {
|
|
params: {
|
|
limit,
|
|
},
|
|
}
|
|
const include = []
|
|
|
|
if (offset !== null) {
|
|
config.params.offset = offset
|
|
}
|
|
|
|
if (cancelToken !== null) {
|
|
config.cancelToken = cancelToken
|
|
}
|
|
|
|
if (includeFieldOptions) {
|
|
include.push('field_options')
|
|
}
|
|
|
|
if (includeRowMetadata) {
|
|
include.push('row_metadata')
|
|
}
|
|
|
|
if (include.length > 0) {
|
|
config.params.include = include.join(',')
|
|
}
|
|
|
|
if (search) {
|
|
config.params.search = search
|
|
}
|
|
|
|
return client.get(`/database/views/grid/${gridId}/`, config)
|
|
},
|
|
fetchCount({ gridId, search, cancelToken = null }) {
|
|
const config = {
|
|
params: {
|
|
count: true,
|
|
},
|
|
}
|
|
if (cancelToken !== null) {
|
|
config.cancelToken = cancelToken
|
|
}
|
|
|
|
if (search) {
|
|
config.params.search = search
|
|
}
|
|
|
|
return client.get(`/database/views/grid/${gridId}/`, config)
|
|
},
|
|
filterRows({ gridId, rowIds, fieldIds = null }) {
|
|
const data = { row_ids: rowIds }
|
|
|
|
if (fieldIds !== null) {
|
|
data.field_ids = fieldIds
|
|
}
|
|
|
|
return client.post(`/database/views/grid/${gridId}/`, data)
|
|
},
|
|
}
|
|
}
|