System Information
- Strapi Version: 3.6.8
- Operating System: MacOS Catalina
- Database: SQLite
- Node Version: 16.3
- NPM Version: 8.1
- Yarn Version: 1.22.17
I have a data base “participants”, for which people can subscribe. The form also includes an email field. That one is set to “unique” via the “Advanced” section of the respective strapi backend form.
However, whenever I send data to that database with an email that already exists, strapi does not care at all. It creates all those “subscribers” without complaining.
Any idea why that is?
This is the json:
{
"kind": "collectionType",
"collectionName": "participants",
"info": {
"name": "Participant",
"description": ""
},
"options": {
"increments": true,
"timestamps": true,
"draftAndPublish": true
},
"pluginOptions": {},
"attributes": {
"expertise": {
"type": "component",
"repeatable": false,
"component": "questions.one-possible-answer-text"
},
"result_id": {
"via": "participant_id",
"collection": "result"
},
"jsondata": {
"type": "json"
},
"salutation": {
"type": "enumeration",
"enum": [
"female",
"male",
"other"
]
},
"first_name": {
"type": "string"
},
"middle_initial": {
"type": "string"
},
"last_name": {
"type": "string"
},
"date_of_birth": {
"type": "string",
"regex": "(\\d{4})-(\\d{2})-(\\d{2})"
},
"email": {
"type": "email",
"required": true,
"private": false,
"unique": true
},
"phone": {
"type": "string",
"regex": "[+]*[(]?[0-9]{1,4}[)]?[-\\s\\./0-9]*$"
},
"display_name": {
"type": "string"
},
"experiment_group": {
"model": "experiment-group"
},
"expert": {
"type": "boolean",
"default": false,
"required": true
},
"listening_experience": {
"type": "string"
},
"p_experts": {
"via": "participants",
"collection": "p-expert"
},
"p_non_experts": {
"via": "participants",
"collection": "p-non-expert"
}
}
}
```
The participant controller saves the data just like this:
```js
let data = ctx.request.body
// add 2 more things
data.experiment_group = groupToAssignParticipantTo.id
data.expert = newParticipantIsExpert
// Create subscriber
entity = await strapi.services.participant.create(data);
```