File tree Expand file tree Collapse file tree 2 files changed +29
-3
lines changed Expand file tree Collapse file tree 2 files changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -21,20 +21,23 @@ const post1 = {
2121 id : '1' ,
2222 title : 'a' ,
2323 views : 100 ,
24+ published : true ,
2425 author : { name : 'foo' } ,
2526 tags : [ 'foo' , 'bar' ] ,
2627}
2728const post2 = {
2829 id : '2' ,
2930 title : 'b' ,
3031 views : 200 ,
32+ published : false ,
3133 author : { name : 'bar' } ,
3234 tags : [ 'bar' ] ,
3335}
3436const post3 = {
3537 id : '3' ,
3638 title : 'c' ,
3739 views : 300 ,
40+ published : false ,
3841 author : { name : 'baz' } ,
3942 tags : [ 'foo' ] ,
4043}
@@ -183,7 +186,16 @@ await test('find', async (t) => {
183186 params : { _sort : '-views,id' } ,
184187 res : [ post3 , post2 , post1 ] ,
185188 } ,
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+ } ,
187199 {
188200 name : POSTS ,
189201 params : { _start : 0 , _end : 2 } ,
Original file line number Diff line number Diff line change @@ -285,12 +285,26 @@ export class Service {
285285 }
286286 // item_ne=value
287287 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+ }
289296 break
290297 }
291298 // item=value
292299 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+ }
294308 }
295309 }
296310 }
You can’t perform that action at this time.
0 commit comments