routeGetAll method
WebRoute
routeGetAll(
- String path, {
- required WebRequest rq,
- List<
String> methods = const [RequestMethods.GET], - Future<
ApiDoc> ? apiDoc()?, - WaAuthController? auth,
- List<
String> extraPath = const [], - List<
String> excludePaths = const [], - List<
String> hosts = const ['*'], - Map<
String, Object?> params = const {}, - List<
String> permissions = const [], - List<
int> ports = const [], - List<
WebRoute> children = const [], - bool paging = true,
- int pageSize = 20,
- bool orderReverse = true,
- String orderBy = '_id',
Implementation
WebRoute routeGetAll(String path,
{required WebRequest rq,
List<String> methods = const [RequestMethods.GET],
Future<ApiDoc>? Function()? apiDoc,
WaAuthController? auth,
List<String> extraPath = const [],
List<String> excludePaths = const [],
List<String> hosts = const ['*'],
Map<String, Object?> params = const {},
List<String> permissions = const [],
List<int> ports = const [],
List<WebRoute> children = const [],
bool paging = true,
int pageSize = 20,
bool orderReverse = true,
String orderBy = '_id'}) {
final index = () async {
if (paging == false) {
var all = await getAll(
filter: getSearchableFilter(inputs: rq.getAllData()),
);
return rq.renderData(data: {
'success': true,
'data': all,
});
} else {
final countAll = await getCount(
filter: getSearchableFilter(inputs: rq.getAllData()),
);
pageSize = rq.get<int>('pageSize', def: pageSize);
orderBy = rq.get<String>('orderBy', def: orderBy);
orderReverse = rq.get<bool>('orderReverse', def: orderReverse);
UIPaging paging = UIPaging(
rq: rq,
total: countAll,
pageSize: pageSize,
widget: '',
page: rq.get<int>('page', def: 1),
orderReverse: orderReverse,
orderBy: orderBy,
);
final res = await getAll(
filter: getSearchableFilter(inputs: rq.getAllData()),
limit: paging.pageSize,
skip: paging.start,
sort: DQ.order(orderBy, orderReverse),
);
return rq.renderData(data: {
'success': true,
'data': res,
'paging': await paging.renderData(),
});
}
};
return WebRoute(
path: path,
methods: methods,
rq: rq,
apiDoc: apiDoc,
auth: auth,
excludePaths: excludePaths,
extraPath: extraPath,
hosts: hosts,
params: params,
permissions: permissions,
ports: ports,
index: index,
children: children,
);
}