Skip to content

Commit

Permalink
add fulltext operator
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg committed Jan 11, 2023
1 parent 191f4bf commit ee62eb0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,25 @@ Through the REST API:
/messages?label[$overlap][0]=important&label[$overlap][1]=work&label[$overlap][2]=urgent
```

### $fulltext

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 :

```js
app.service('messages').find({
query: {
labels: {
$contained_by: ['important', 'work', 'urgent']
}
}
});
```

Through the REST API:

```
/messages?label[$contained_by][0]=important&label[$contained_by][1]=work&label[$contained_by][2]=urgent
```

## Transaction Support

Expand Down
5 changes: 3 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ const OPERATORS = {
$ilike: 'ilike',
$overlap: '&&',
$contains: '@>',
$contained_by: '<@'
$contained_by: '<@',
$fulltext: '@@'
};

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

this.table = options.name;
Expand Down

0 comments on commit ee62eb0

Please sign in to comment.