MCPcopy Index your code
hub / github.com/apache/pouchdb / filterInMemoryFields

Function filterInMemoryFields

lib/index.es.js:3596–3618  ·  view source on GitHub ↗
(rows, requestDef, inMemoryFields)

Source from the content-addressed store, hash-verified

3594}
3595
3596function filterInMemoryFields(rows, requestDef, inMemoryFields) {
3597 rows = rows.filter(function (row) {
3598 return rowFilter(row.doc, requestDef.selector, inMemoryFields);
3599 });
3600
3601 if (requestDef.sort) {
3602 // in-memory sort
3603 var fieldSorter = createFieldSorter(requestDef.sort);
3604 rows = rows.sort(fieldSorter);
3605 if (typeof requestDef.sort[0] !== 'string' &&
3606 getValue(requestDef.sort[0]) === 'desc') {
3607 rows = rows.reverse();
3608 }
3609 }
3610
3611 if ('limit' in requestDef || 'skip' in requestDef) {
3612 // have to do the limit in-memory
3613 var skip = requestDef.skip || 0;
3614 var limit = ('limit' in requestDef ? requestDef.limit : rows.length) + skip;
3615 rows = rows.slice(skip, limit);
3616 }
3617 return rows;
3618}
3619
3620function rowFilter(doc, selector, inMemoryFields) {
3621 return inMemoryFields.every(function (field) {

Callers 1

matchesSelectorFunction · 0.70

Calls 3

rowFilterFunction · 0.70
createFieldSorterFunction · 0.70
getValueFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…