File tree 2 files changed +29
-3
lines changed
2 files changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -21,20 +21,23 @@ const post1 = {
21
21
id : '1' ,
22
22
title : 'a' ,
23
23
views : 100 ,
24
+ published : true ,
24
25
author : { name : 'foo' } ,
25
26
tags : [ 'foo' , 'bar' ] ,
26
27
}
27
28
const post2 = {
28
29
id : '2' ,
29
30
title : 'b' ,
30
31
views : 200 ,
32
+ published : false ,
31
33
author : { name : 'bar' } ,
32
34
tags : [ 'bar' ] ,
33
35
}
34
36
const post3 = {
35
37
id : '3' ,
36
38
title : 'c' ,
37
39
views : 300 ,
40
+ published : false ,
38
41
author : { name : 'baz' } ,
39
42
tags : [ 'foo' ] ,
40
43
}
@@ -183,7 +186,16 @@ await test('find', async (t) => {
183
186
params : { _sort : '-views,id' } ,
184
187
res : [ post3 , post2 , post1 ] ,
185
188
} ,
186
-
189
+ {
190
+ name : POSTS ,
191
+ params : { published : 'true' } ,
192
+ res : [ post1 ] ,
193
+ } ,
194
+ {
195
+ name : POSTS ,
196
+ params : { published : 'false' } ,
197
+ res : [ post2 , post3 ] ,
198
+ } ,
187
199
{
188
200
name : POSTS ,
189
201
params : { _start : 0 , _end : 2 } ,
Original file line number Diff line number Diff line change @@ -285,12 +285,26 @@ export class Service {
285
285
}
286
286
// item_ne=value
287
287
case Condition . ne : {
288
- if ( ! ( itemValue != paramValue ) ) return false
288
+ switch ( typeof itemValue ) {
289
+ case 'number' :
290
+ return itemValue !== parseInt ( paramValue )
291
+ case 'string' :
292
+ return itemValue !== paramValue
293
+ case 'boolean' :
294
+ return itemValue !== ( paramValue === 'true' )
295
+ }
289
296
break
290
297
}
291
298
// item=value
292
299
case Condition . default : {
293
- if ( ! ( itemValue == paramValue ) ) return false
300
+ switch ( typeof itemValue ) {
301
+ case 'number' :
302
+ return itemValue === parseInt ( paramValue )
303
+ case 'string' :
304
+ return itemValue === paramValue
305
+ case 'boolean' :
306
+ return itemValue === ( paramValue === 'true' )
307
+ }
294
308
}
295
309
}
296
310
}
You can’t perform that action at this time.
0 commit comments