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
22 lines
698 B
Plaintext
22 lines
698 B
Plaintext
import ObjectIdImport from 'bson-objectid';
|
|
const ObjectId = 'default' in ObjectIdImport ? ObjectIdImport.default : ObjectIdImport;
|
|
export const baseIDField = {
|
|
name: 'id',
|
|
type: 'text',
|
|
admin: {
|
|
hidden: true
|
|
},
|
|
defaultValue: ()=>new ObjectId().toHexString(),
|
|
hooks: {
|
|
beforeChange: [
|
|
({ value })=>value || new ObjectId().toHexString()
|
|
],
|
|
// ID field values for arrays and blocks need to be unique when duplicating, as on postgres they are stored on the same table as primary keys.
|
|
beforeDuplicate: [
|
|
()=>new ObjectId().toHexString()
|
|
]
|
|
},
|
|
label: 'ID'
|
|
};
|
|
|
|
//# sourceMappingURL=baseIDField.js.map |