Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions docs/api/schema/typebox.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const messageQuerySchema = querySyntax(messageQueryProperties)
type MessageQuery = Static<typeof messageQuerySchema>
```

Additional special query properties [that are not already included in the query syntax](../databases/querying.md) like `$ilike` can be added like this:
Additional special query properties [that are not already included in the query syntax](../databases/querying.md) like `$regex` can be added like this:

```ts
import { querySyntax } from '@feathersjs/typebox'
Expand All @@ -108,10 +108,10 @@ const messageQueryProperties = Type.Pick(messageSchema, ['id', 'text', 'createdA
})
const messageQuerySchema = Type.Intersect(
[
// This will additionally allow querying for `{ name: { $ilike: 'Dav%' } }`
// This will additionally allow querying for `{ name: { $regex: 'Dav', $options: 'i' } }`
querySyntax(messageQueryProperties, {
name: {
$ilike: Type.String()
$regex: Type.String(), $options: Type.String()
}
}),
// Add additional query properties here
Expand All @@ -121,6 +121,18 @@ const messageQuerySchema = Type.Intersect(
)
```

Finally, in the class module, add the operators:

```ts
export const getOptions = (app: Application): MongoDBAdapterOptions => {
return {
paginate: app.get('paginate'),
Model: app.get('mongodbClient').then((db) => db.collection('example')),
operators: ['$regex', '$options'] // add the operators
}
}
```

To allow additional query properties outside of the query syntax use the intersection type:

```ts
Expand Down