mirror of
https://github.com/strapi/strapi.git
synced 2025-11-02 19:04:38 +00:00
Remove primarykey from possible mainField with string type
This commit is contained in:
parent
6f82a4ea48
commit
7f90bdb5b9
@ -24,6 +24,7 @@ async function createDefaultConfiguration(model) {
|
||||
// convert model to schema
|
||||
|
||||
const schema = formatContentTypeSchema(model);
|
||||
schema.primaryKey = model.primaryKey;
|
||||
|
||||
if (model.config) {
|
||||
await validateCustomConfig(model, schema);
|
||||
@ -40,6 +41,7 @@ async function createDefaultConfiguration(model) {
|
||||
async function syncConfiguration(conf, model) {
|
||||
// convert model to schema
|
||||
const schema = formatContentTypeSchema(model);
|
||||
schema.primaryKey = model.primaryKey;
|
||||
|
||||
if (model.config) {
|
||||
await validateCustomConfig(model, schema);
|
||||
|
||||
@ -29,11 +29,11 @@ function createDefaultMetadatas(schema) {
|
||||
function createDefaultMainField(schema) {
|
||||
if (!schema) return 'id';
|
||||
|
||||
return (
|
||||
Object.keys(schema.attributes).find(
|
||||
key => schema.attributes[key].type === 'string'
|
||||
) || 'id'
|
||||
const mainField = Object.keys(schema.attributes).find(
|
||||
key => schema.attributes[key].type === 'string' && key !== schema.primaryKey
|
||||
);
|
||||
|
||||
return mainField || 'id';
|
||||
}
|
||||
|
||||
function createDefaultMetadata(schema, name) {
|
||||
@ -150,7 +150,10 @@ const getTargetSchema = (name, plugin) => {
|
||||
const model = strapi.getModel(name, plugin);
|
||||
if (!model) return null;
|
||||
|
||||
return formatContentTypeSchema(model);
|
||||
return {
|
||||
...formatContentTypeSchema(model),
|
||||
primaryKey: model.primaryKey,
|
||||
};
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user