middleware/_modelIndex.js
function (cb) {

                const getDefaultOrder = field => field.defaultOrder.toLowerCase() === 'desc' ? '-' : '';

                if (!session.list.formData.sort && req.linz.model.list.sortBy.length) {

                    req.linz.model.list.sortingBy = req.linz.model.list.sortBy[0];

                    // set default form sort
                    session.list.formData.sort = `${getDefaultOrder(req.linz.model.list.sortingBy)}${req.linz.model.list.sortingBy.field}`;

                } else {

                    req.linz.model.list.sortBy.forEach(function (sort) {

                        if (sort.field === session.list.formData.sort || '-' + sort.field === session.list.formData.sort) {
                            req.linz.model.list.sortingBy = sort;
                        }

                    });

                }

                query.sort(session.list.formData.sort);

                if (req.linz.model.list.paging.active === true) {
                    // add in paging skip and limit
                    query.skip(pageIndex*pageSize-pageSize).limit(pageSize);
                }

                query.exec(function (err, docs) {

                    // A query error has occured, let's short circuit this entire process
                    // and start again from the last known working state.
                    if (err) {
                        return handleQueryError(err);
                    }

                    if (!err && docs.length === 0) {

                        return cb(new Error('No records found'));

                    }

                    if (!err) {

                        mongooseRecords = docs;
                        // convert mongoose documents to plain javascript objects
                        mongooseRecords.forEach(function (record) {
                            records.push(record.toObject({ virtuals: true}));
                        });

                    }

                    cb(err);

                });

            }
function (cb) {

                const getDefaultOrder = field => field.defaultOrder.toLowerCase() === 'desc' ? '-' : '';

                if (!session.list.formData.sort && req.linz.model.list.sortBy.length) {

                    req.linz.model.list.sortingBy = req.linz.model.list.sortBy[0];

                    // set default form sort
                    session.list.formData.sort = `${getDefaultOrder(req.linz.model.list.sortingBy)}${req.linz.model.list.sortingBy.field}`;

                } else {

                    req.linz.model.list.sortBy.forEach(function (sort) {

                        if (sort.field === session.list.formData.sort || '-' + sort.field === session.list.formData.sort) {
                            req.linz.model.list.sortingBy = sort;
                        }

                    });

                }

                query.sort(session.list.formData.sort);

                if (req.linz.model.list.paging.active === true) {
                    // add in paging skip and limit
                    query.skip(pageIndex*pageSize-pageSize).limit(pageSize);
                }

                query.exec(function (err, docs) {

                    // A query error has occured, let's short circuit this entire process
                    // and start again from the last known working state.
                    if (err) {
                        return handleQueryError(err);
                    }

                    if (!err && docs.length === 0) {

                        return cb(new Error('No records found'));

                    }

                    if (!err) {

                        mongooseRecords = docs;
                        // convert mongoose documents to plain javascript objects
                        mongooseRecords.forEach(function (record) {
                            records.push(record.toObject({ virtuals: true}));
                        });

                    }

                    cb(err);

                });

            }
function ( cb ) { const getDefaultOrder = field => field . defaultOrder . toLowerCase ( ) === 'desc' ? '-' : '' ; if ( ! session . list . formData . sort && req . linz . model . list . sortBy . length ) { req . linz . model . list . sortingBy = req . linz . model . list . sortBy [ 0 ] ; // set default form sort session . list . formData . sort = ` ${ getDefaultOrder ( req . linz . model . list . sortingBy ) } ${ req . linz . model . list . sortingBy . field } ` ; } else { req . linz . model . list . sortBy . forEach ( function ( sort ) { if ( sort . field === session . list . formData . sort || '-' + sort . field === session . list . formData . sort ) { req . linz . model . list . sortingBy = sort ; } } ) ; } query . sort ( session . list . formData . sort ) ; if ( req . linz . model . list . paging . active === true ) { // add in paging skip and limit query . skip ( pageIndex * pageSize - pageSize ) . limit ( pageSize ) ; } query . exec ( function ( err , docs ) { // A query error has occured, let's short circuit this entire process // and start again from the last known working state. if ( err ) { return handleQueryError ( err ) ; } if ( ! err && docs . length === 0 ) { return cb ( new Error ( 'No records found' ) ) ; } if ( ! err ) { mongooseRecords = docs ; // convert mongoose documents to plain javascript objects mongooseRecords . forEach ( function ( record ) { records . push ( record . toObject ( { virtuals : true } ) ) ; } ) ; } cb ( err ) ; } ) ; }
find the docs
find the docs