+17
-2
lines changedFilter options
+17
-2
lines changed Original file line number Diff line number Diff line change
@@ -109,7 +109,7 @@ export default class Builder {
109
109
if (Array.isArray(key)) {
110
110
const [_key, _value] = this._nestedFilter(key, value)
111
111
112
-
this.filters[_key] = _value
112
+
this.filters[_key] = { ...this.filters[_key], ..._value }
113
113
} else {
114
114
this.filters[key] = value
115
115
}
@@ -125,7 +125,7 @@ export default class Builder {
125
125
if (Array.isArray(key)) {
126
126
const [_key, _value] = this._nestedFilter(key, array.join(','))
127
127
128
-
this.filters[_key] = _value
128
+
this.filters[_key] = { ...this.filters[_key], ..._value }
129
129
} else {
130
130
this.filters[key] = array.join(',')
131
131
}
Original file line number Diff line number Diff line change
@@ -121,6 +121,13 @@ describe('Query builder', () => {
121
121
122
122
expect(post._builder.filters).toEqual({ user: { status: 'active' } })
123
123
expect(post._builder.query()).toEqual('?filter[user][status]=active')
124
+
125
+
post = Post
126
+
.where(['schedule', 'start'], '2020-11-27')
127
+
.where(['schedule', 'end'], '2020-11-28')
128
+
129
+
expect(post._builder.filters).toEqual({ schedule: { start: '2020-11-27', end: '2020-11-28' } })
130
+
expect(post._builder.query()).toEqual('?filter[schedule][start]=2020-11-27&filter[schedule][end]=2020-11-28')
124
131
})
125
132
126
133
test('where() throws a exception when doest not have params or only first param', () => {
@@ -152,7 +159,15 @@ describe('Query builder', () => {
152
159
153
160
post = Post.whereIn(['user', 'status'], ['active', 'inactive'])
154
161
162
+
expect(post._builder.filters).toEqual({ user: { status: 'active,inactive' } })
155
163
expect(post._builder.query()).toEqual('?filter[user][status]=active,inactive')
164
+
165
+
post = Post
166
+
.whereIn(['schedule', 'start'], ['2020-11-27', '2020-11-28'])
167
+
.whereIn(['schedule', 'end'], ['2020-11-28', '2020-11-29'])
168
+
169
+
expect(post._builder.filters).toEqual({ schedule: { start: '2020-11-27,2020-11-28', end: '2020-11-28,2020-11-29' } })
170
+
expect(post._builder.query()).toEqual('?filter[schedule][start]=2020-11-27,2020-11-28&filter[schedule][end]=2020-11-28,2020-11-29')
156
171
})
157
172
158
173
test('whereIn() throws a exception when second parameter is not a array', () => {
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4