Created
August 25, 2014 15:11
-
-
Save prestonp/d28ef73a8ebbc79bea55 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mosql.registerConditionalHelper( '$matches', function( column, set, values, collection ) { | |
return column + ' @@ plainto_tsquery(' + set + ')'; | |
}); | |
mosql.registerConditionalHelper( '$partialMatches', function( column, set, values, collection ) { | |
// This breaks down a query for prefix matching. | |
// The limitation is it does not support spaces | |
// but rather & (AND) and | (OR) and ! (NOT). | |
// Ex to_tsquery('cat & hat & !ham') -- works | |
// to_tsquery('cat in the hat') -- error! | |
return column + ' @@ to_tsquery(' + set + '||\':*\')'; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment