File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,8 @@ module.exports = (function() {
12
12
'ilike' : function ( a , b ) { return a . toLowerCase ( ) . indexOf ( b . toLowerCase ( ) ) > - 1 ; } ,
13
13
'like' : function ( a , b ) { return a . indexOf ( b ) > - 1 ; } ,
14
14
'in' : function ( a , b ) { return b . indexOf ( a ) > - 1 ; } ,
15
- 'not_in' : function ( a , b ) { return b . indexOf ( a ) === - 1 ; }
15
+ 'not_in' : function ( a , b ) { return b . indexOf ( a ) === - 1 ; } ,
16
+ 'starts_with' : function ( a , b ) { return a . substr ( 0 , b . length ) === b ; }
16
17
} ;
17
18
18
19
class Query {
Original file line number Diff line number Diff line change @@ -394,6 +394,17 @@ describe('Test Suite', function() {
394
394
395
395
} ) ;
396
396
397
+ it ( 'should filter starts_with' , function ( ) {
398
+
399
+ expect ( nc . query ( ) . filter ( { name__starts_with : 'Keith' } ) . units ( ) . length ) . to . equal ( 1 ) ;
400
+ expect ( nc . query ( ) . filter ( { name__starts_with : 'Keith' } ) . first ( ) ) . to . equal ( nc . find ( 1 ) ) ;
401
+
402
+ expect ( nc . query ( ) . filter ( { name__starts_with : 'K' } ) . units ( ) . length ) . to . equal ( 2 ) ;
403
+ expect ( nc . query ( ) . filter ( { name__starts_with : 'K' } ) . first ( ) ) . to . equal ( nc . find ( 1 ) ) ;
404
+ expect ( nc . query ( ) . filter ( { name__starts_with : 'K' } ) . units ( ) [ 1 ] ) . to . equal ( nc . find ( 4 ) ) ;
405
+
406
+ } ) ;
407
+
397
408
it ( 'should exclude as expected' , function ( ) {
398
409
399
410
expect ( nc . query ( ) . exclude ( { name__is : 'Keith' } ) . first ( ) ) . to . equal ( nc . find ( 2 ) ) ;
You can’t perform that action at this time.
0 commit comments