listo carga de datos en localstorage
This commit is contained in:
@@ -12,11 +12,15 @@ export default defineEventHandler(async (event) => {
|
||||
const limitValue = Number.parseInt((query.limit as string) ?? '', 10)
|
||||
const limit = Number.isFinite(limitValue) ? Math.min(Math.max(limitValue, 1), 500) : undefined
|
||||
|
||||
const offsetValue = Number.parseInt((query.offset as string) ?? '', 10)
|
||||
const offset = Number.isFinite(offsetValue) ? Math.max(offsetValue, 0) : undefined
|
||||
|
||||
const parsedQuery = parseQuerySegment(query.query as string | undefined)
|
||||
|
||||
return await fetchTableData(table, {
|
||||
parsedQuery,
|
||||
limit,
|
||||
offset,
|
||||
filters: {
|
||||
id: (query.id as string) || undefined,
|
||||
createdFrom: (query.created_from as string) || undefined,
|
||||
|
||||
@@ -3,5 +3,6 @@ import type { TableConfig } from '../types'
|
||||
export const vistaResumenIngresosConfig: TableConfig = {
|
||||
name: 'vista_resumen_ingresos',
|
||||
table: 'vista_resumen_ingresos',
|
||||
primaryKey: 'id'
|
||||
primaryKey: 'id',
|
||||
defaultSelect: '*, fecha as created_at'
|
||||
}
|
||||
@@ -3,5 +3,6 @@ import type { TableConfig } from '../types'
|
||||
export const vistaResumenIngresosPorComercioConfig: TableConfig = {
|
||||
name: 'vista_resumen_ingresos_por_comercio',
|
||||
table: 'vista_resumen_ingresos_por_comercio',
|
||||
primaryKey: 'id'
|
||||
primaryKey: 'id',
|
||||
defaultSelect: '*, fecha as created_at'
|
||||
}
|
||||
@@ -23,6 +23,7 @@ interface DataOptions {
|
||||
parsedQuery?: ParsedQuery | null
|
||||
filters?: DataFilters
|
||||
limit?: number
|
||||
offset?: number
|
||||
}
|
||||
|
||||
function serializeRow(row: unknown, config: TableConfig): GenericObject | null {
|
||||
@@ -261,6 +262,10 @@ export async function fetchTableData(tableName: string, options?: DataOptions) {
|
||||
query = query.limit(limit)
|
||||
}
|
||||
|
||||
if (options?.offset !== undefined && options.offset > 0) {
|
||||
query = query.range(options.offset, options.offset + limit - 1)
|
||||
}
|
||||
|
||||
const { data, error, count } = await query
|
||||
|
||||
if (error) {
|
||||
|
||||
Reference in New Issue
Block a user