Skip to content

Commit 77b06b8

Browse files
author
Greg
committed
add fulltext operator
1 parent c3caff9 commit 77b06b8

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

README.md

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

291+
### $fulltext
292+
293+
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 :
294+
295+
```js
296+
app.service('messages').find({
297+
query: {
298+
labels: {
299+
$contained_by: ['important', 'work', 'urgent']
300+
}
301+
}
302+
});
303+
```
304+
305+
Through the REST API:
306+
307+
```
308+
/messages?label[$contained_by][0]=important&label[$contained_by][1]=work&label[$contained_by][2]=urgent
309+
```
291310

292311
## Transaction Support
293312

lib/index.js

Lines changed: 3 additions & 2 deletions
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)