Merge pull request #5100 from strapi/fix/main-field-exclude-id

Fix main field set to id on mongo
This commit is contained in:
Alexandre BODIN 2020-01-27 12:14:16 +01:00 committed by GitHub
commit 3c59a05154
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -30,7 +30,9 @@ function createDefaultMainField(schema) {
if (!schema) return 'id';
const mainField = Object.keys(schema.attributes).find(
key => schema.attributes[key].type === 'string' && key !== schema.primaryKey
key =>
schema.attributes[key].type === 'string' &&
!['id', schema.primaryKey].includes(key)
);
return mainField || 'id';