klark-js-plugins
Advanced tools
Comparing version 1.0.22 to 1.0.23
@@ -0,0 +0,0 @@ { |
{ | ||
"vsicons.presets.angular": false | ||
} |
{ | ||
"name": "klark-js-plugins", | ||
"version": "1.0.22", | ||
"version": "1.0.23", | ||
"description": "Plugin modules for KlarkJS", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -11,3 +11,7 @@ 'use strict'; | ||
count: count, | ||
remove: remove | ||
remove: remove, | ||
appliers: { | ||
applyPagination, | ||
applyFilters | ||
} | ||
}; | ||
@@ -33,13 +37,3 @@ | ||
var q; | ||
if (filters) { | ||
q = _.transform(filters, function(result, value, key) { | ||
if (key === '__custom__' && _.isFunction(value)) { | ||
value(result); | ||
} else if (!(_.isNil(value) || (_.isString(value) && !value))) { | ||
result[key] = valueToFilter(value); | ||
} | ||
}, {}); | ||
} | ||
const q = applyFilters(cursor, filters); | ||
var cursor = model.find(q); | ||
@@ -52,10 +46,3 @@ | ||
if (pagination) { | ||
if (pagination.page) { | ||
krkLogger.assert(pagination.count > 0); | ||
cursor.skip((pagination.page - 1) * pagination.count) | ||
.limit(pagination.count); | ||
} | ||
if (pagination.sortBy) { | ||
cursor.sort(_.fromPairs([[pagination.sortBy, pagination.asc ? 1 : -1]])); | ||
} | ||
applyPagination(cursor, pagination); | ||
} | ||
@@ -88,2 +75,27 @@ | ||
} | ||
function applyPagination(cursor, pagination) { | ||
if (pagination) { | ||
if (pagination.page) { | ||
krkLogger.assert(pagination.count > 0); | ||
cursor.skip((pagination.page - 1) * pagination.count) | ||
.limit(pagination.count); | ||
} | ||
if (pagination.sortBy) { | ||
cursor.sort(_.fromPairs([[pagination.sortBy, pagination.asc ? 1 : -1]])); | ||
} | ||
} | ||
} | ||
function applyFilters(cursor, filters) { | ||
if (filters) { | ||
return _.transform(filters, function(result, value, key) { | ||
if (key === '__custom__' && _.isFunction(value)) { | ||
value(result); | ||
} else if (!(_.isNil(value) || (_.isString(value) && !value))) { | ||
result[key] = valueToFilter(value); | ||
} | ||
}, {}); | ||
} | ||
} | ||
}); |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ # klark plugins |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
77656
34
1919