mirror of
https://github.com/strapi/strapi.git
synced 2025-11-12 16:22:10 +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
|
// convert model to schema
|
||||||
|
|
||||||
const schema = formatContentTypeSchema(model);
|
const schema = formatContentTypeSchema(model);
|
||||||
|
schema.primaryKey = model.primaryKey;
|
||||||
|
|
||||||
if (model.config) {
|
if (model.config) {
|
||||||
await validateCustomConfig(model, schema);
|
await validateCustomConfig(model, schema);
|
||||||
@ -40,6 +41,7 @@ async function createDefaultConfiguration(model) {
|
|||||||
async function syncConfiguration(conf, model) {
|
async function syncConfiguration(conf, model) {
|
||||||
// convert model to schema
|
// convert model to schema
|
||||||
const schema = formatContentTypeSchema(model);
|
const schema = formatContentTypeSchema(model);
|
||||||
|
schema.primaryKey = model.primaryKey;
|
||||||
|
|
||||||
if (model.config) {
|
if (model.config) {
|
||||||
await validateCustomConfig(model, schema);
|
await validateCustomConfig(model, schema);
|
||||||
|
|||||||
@ -29,11 +29,11 @@ function createDefaultMetadatas(schema) {
|
|||||||
function createDefaultMainField(schema) {
|
function createDefaultMainField(schema) {
|
||||||
if (!schema) return 'id';
|
if (!schema) return 'id';
|
||||||
|
|
||||||
return (
|
const mainField = Object.keys(schema.attributes).find(
|
||||||
Object.keys(schema.attributes).find(
|
key => schema.attributes[key].type === 'string' && key !== schema.primaryKey
|
||||||
key => schema.attributes[key].type === 'string'
|
|
||||||
) || 'id'
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return mainField || 'id';
|
||||||
}
|
}
|
||||||
|
|
||||||
function createDefaultMetadata(schema, name) {
|
function createDefaultMetadata(schema, name) {
|
||||||
@ -150,7 +150,10 @@ const getTargetSchema = (name, plugin) => {
|
|||||||
const model = strapi.getModel(name, plugin);
|
const model = strapi.getModel(name, plugin);
|
||||||
if (!model) return null;
|
if (!model) return null;
|
||||||
|
|
||||||
return formatContentTypeSchema(model);
|
return {
|
||||||
|
...formatContentTypeSchema(model),
|
||||||
|
primaryKey: model.primaryKey,
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user