Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
16 lines
820 B
Plaintext
16 lines
820 B
Plaintext
/**
|
|
* While the default ID is determined by the db adapter, it can still differ for a collection if they
|
|
* define a custom ID field. This builds a map of collection slugs to their ID field type.
|
|
* @param defaultIDType as defined by the database adapter
|
|
*/ export function getCollectionIDFieldTypes({ config, defaultIDType }) {
|
|
return config.collections.reduce((acc, collection)=>{
|
|
const customCollectionIdField = collection.fields.find((field)=>'name' in field && field.name === 'id');
|
|
acc[collection.slug] = defaultIDType === 'text' ? 'string' : 'number';
|
|
if (customCollectionIdField) {
|
|
acc[collection.slug] = customCollectionIdField.type === 'number' ? 'number' : 'string';
|
|
}
|
|
return acc;
|
|
}, {});
|
|
}
|
|
|
|
//# sourceMappingURL=getCollectionIDFieldTypes.js.map |