System Information
- Strapi Version: 3.6.2
- Operating System: Ubuntu 20.04
- Database: MongoDB
- Node Version: v14.16.0
- NPM Version: 6.14.11
- Yarn Version: 0.32+git
Consider the following models and components:
Identity
...
{
"kind": "collectionType",
"collectionName": "identities",
"info": {
"name": "Identity",
"description": ""
},
"attributes": {
"externalId": {
"type": "string"
},
...
"createdDate": {
"type": "datetime"
},
"contact": {
"type": "component",
"repeatable": false,
"component": "contact.contact"
},
...
and this component:
contact:
...
{
"collectionName": "components_contact_contacts",
"info": {
"name": "Contact",
"icon": "address-card",
"description": ""
},
"options": {},
"attributes": {
"email": {
"type": "email"
},
"phoneNumber": {
"type": "string"
},
...
And here are some database records:
[
{
"role": "client",
"plan": "basic",
"status": "active",
"_id": "60bef6b955444c0013a10816",
"externalId": "johndoe",
"published_at": "2021-06-08T04:48:57.236Z",
"contact": {
"_id": "60bef6b955444c0013a10817",
"firstName": "John",
"lastName": "Doe",
"email": "jd@example.com",
"address": "1 Yonge Street",
"city": "Toronto",
"postalCode": "",
"country": "Canada",
"phoneNumber": "8888888888",
"__v": 0,
"id": "60bef6b955444c0013a10817"
},
"createdAt": "2021-06-08T04:48:57.269Z",
"updatedAt": "2021-06-08T04:48:57.301Z",
"__v": 1,
"id": "60bef6b955444c0013a10816"
},
{
"role": "client",
"plan": "basic",
"status": "active",
"_id": "60cb6024318e38070b3d7fb2",
"externalId": "18",
"published_at": "2021-06-17T14:45:56.908Z",
"contact": {
"_id": "60d10a641409c91e66600a5d",
"firstName": "Jane",
"lastName": "Doe",
"email": "jd2@example.com",
"address": "",
"city": "",
"postalCode": "",
"country": "",
"phoneNumber": "",
"__v": 0,
"id": "60d10a641409c91e66600a5d"
},
"createdAt": "2021-06-17T14:45:56.937Z",
"updatedAt": "2021-06-21T21:53:40.463Z",
"__v": 8
},
"id": "60cb6024318e38070b3d7fb2"
},
...]
How do you query by the contact.email
?
I’ve tried this query, and it doesn’t seem to work:
http://localhost:31337/identities?contact.email=jd@example.com
Response:
{
"statusCode": 400,
"error": "Bad Request",
"message": "Your filters contain a field 'contact.email' that doesn't appear on your model definition nor its relations"
}