Repository navigation
Typebox QuerySchema - Querying array mongoDB #3059
Replies: 3 comments 1 reply
|
I think the best way to address this would be to customise the query properties. So instead of export const contactsQueryProperties = Type.Pick(contactsSchema, ['contactTags', 'deletable'])Use export const contactsQueryProperties = Type.Object({
contactTags: Type.Number(),
deletable: Type.Boolean()
})This should create the query syntax you are looking for. |
|
I can confirm that this makes EDIT: Perhaps there's a chance the changes to |
|
Querying with |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
My feathers version is 5.0.0-pre.37
My service schema is:
The query I want to perform is:
http://localhost:3032/contacts?$or[1][contactTags]=1&$or[0][deletable]=true
What works is
http://localhost:3032/contacts?contactTags=1
But when using the query with $or, the contactTags: Type.Number() (which is necessary to have the query working without $or) seems not to be passed to the query validator.
The error is:
{ "name": "BadRequest", "message": "validation failed", "code": 400, "className": "bad-request", "data": [ { "instancePath": "/$or/1/contactTags", "schemaPath": "#/properties/%24or/items/properties/contactTags/anyOf/0/type", "keyword": "type", "params": { "type": "array" }, "message": "must be array" }, { "instancePath": "/$or/1/contactTags", "schemaPath": "#/properties/%24or/items/properties/contactTags/anyOf/1/type", "keyword": "type", "params": { "type": "object" }, "message": "must be object" }, { "instancePath": "/$or/1/contactTags", "schemaPath": "#/properties/%24or/items/properties/contactTags/anyOf", "keyword": "anyOf", "params": {}, "message": "must match a schema in anyOf" } ] }Perhaps I need to adjust the querySyntax with expanding $or? But how?
All reactions