FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

docs(Typebox): Schema for allowed query properties by Sciederrick · Pull Request #3518 · feathersjs/feathers · GitHub

Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .md  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
18 changes: 15 additions & 3 deletions docs/api/schema/typebox.md
This file contains hidden or 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
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

Back | FazBrowse Home | New Git URL