Skip to content
This repository was archived by the owner on Nov 9, 2021. It is now read-only.

.setFields with 'exclude' option with an array of fields to exclude #238

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions squel.js
Original file line number Diff line number Diff line change
@@ -1706,6 +1706,16 @@ function _buildSquel() {
value: function _setFields(fields) {
var valueOptions = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];

if (Array.isArray(valueOptions.exclude)) {
fields = Object.keys(fields);
.reduce(function (result, field) {
if (valueOptions.exclude.indexOf(field) === -1) {
result[field] = fields[field];
}
return result;
}, {})
}

if ((typeof fields === 'undefined' ? 'undefined' : _typeof(fields)) !== 'object') {
throw new Error("Expected an object but got " + (typeof fields === 'undefined' ? 'undefined' : _typeof(fields)));
}