Skip to content

Commit ee62eb0

Browse files
author
Greg
committed
add fulltext operator
1 parent 191f4bf commit ee62eb0

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

README.md

+19
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,25 @@ Through the REST API:
287287
/messages?label[$overlap][0]=important&label[$overlap][1]=work&label[$overlap][2]=urgent
288288
```
289289

290+
### $fulltext
291+
292+
For PostgreSQL only, for fulltext-indexed fields, finds records that match useing postgres' fulltext natural-langauge search. The following query retrieves all messages whose labels contain any of the values `important`, `work`, or `urgent`, but no values outside that list :
293+
294+
```js
295+
app.service('messages').find({
296+
query: {
297+
labels: {
298+
$contained_by: ['important', 'work', 'urgent']
299+
}
300+
}
301+
});
302+
```
303+
304+
Through the REST API:
305+
306+
```
307+
/messages?label[$contained_by][0]=important&label[$contained_by][1]=work&label[$contained_by][2]=urgent
308+
```
290309

291310
## Transaction Support
292311

lib/index.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ const OPERATORS = {
2626
$ilike: 'ilike',
2727
$overlap: '&&',
2828
$contains: '@>',
29-
$contained_by: '<@'
29+
$contained_by: '<@',
30+
$fulltext: '@@'
3031
};
3132

3233
// Create the service.
@@ -45,7 +46,7 @@ class Service extends AdapterService {
4546
super(Object.assign({
4647
id: 'id'
4748
}, options, {
48-
whitelist: whitelist.concat(['$like', '$notlike', '$ilike', '$and', '$overlap', '$contains', '$contained_by'])
49+
whitelist: whitelist.concat(['$like', '$notlike', '$ilike', '$and', '$overlap', '$contains', '$contained_by', '$fulltext'])
4950
}));
5051

5152
this.table = options.name;

0 commit comments

Comments
 (0)