Strapi: Unique cannot be unset with Mongoose

Created on 3 Aug 2018  路  3Comments  路  Source: strapi/strapi




Informations

  • Node.js version: 10.8.0
  • npm version: 6.2.0
  • Strapi version: 3.0.0-alpha.13.0.1
  • Database: mongodb
  • Operating system: Linux

What is the current behavior?
When I create field with unique constraint and then uncheck this checkbox the constraint still exists in the database and therefore it is still effectively unique field.

Steps to reproduce the problem

  • Check the unique checkbox
  • Save
  • Uncheck unique checkbox
  • Save
  • Try to create duplicate record

What is the expected behavior?
I should be able to create two entries with same value given that unique is unset

Suggested solutions

low confirmed bug

Most helpful comment

As a workaround, using MongoDB Compass you can navigate to the collection with the unwanted unique property, and under the indexes tab, you can drop the index in question.
When using the command line you can use dropIndex

All 3 comments

Hello @jskorepa , thank you for reporting this issue. We are currently on another feature and bug fix. Since time is lacking on our side, feel free investigate and submit a PR, we鈥檒l appreciate your contribution on this issue!

Check out the contributing guide to get started: https://github.com/strapi/strapi/blob/master/CONTRIBUTING.md

Likely due to Strapi not modifying the collection, will need to be fixed in the mongoose package.

As a workaround, using MongoDB Compass you can navigate to the collection with the unwanted unique property, and under the indexes tab, you can drop the index in question.
When using the command line you can use dropIndex

Was this page helpful?
0 / 5 - 0 ratings

Related issues

denislutz picture denislutz  路  3Comments

Rashidul420222 picture Rashidul420222  路  3Comments

derrickmehaffy picture derrickmehaffy  路  3Comments

chaitanyya picture chaitanyya  路  3Comments

GreenGremlin picture GreenGremlin  路  3Comments