Update document and email message schemas to allow optional object references
All checks were successful
farmcontrol/farmcontrol-ws/pipeline/head This commit looks good

- Modified the `object` field in both `documentJob` and `emailMessage` schemas to be non-required.
- Introduced a new `objects` array field in both schemas to accommodate multiple optional object references, enhancing flexibility in data management.
This commit is contained in:
Tom Butcher 2026-09-14 23:32:56 +01:00
parent 940c05078e
commit ea80bfb217
2 changed files with 10 additions and 2 deletions

View File

@ -14,8 +14,15 @@ const documentJobSchema = new Schema(
object: { object: {
type: Schema.Types.ObjectId, type: Schema.Types.ObjectId,
refPath: 'objectType', refPath: 'objectType',
required: true, required: false,
}, },
objects: [
{
type: Schema.Types.ObjectId,
refPath: 'objectType',
required: false,
},
],
state: { state: {
type: { type: String, required: true, default: 'queued' }, type: { type: String, required: true, default: 'queued' },
progress: { type: Number, required: false }, progress: { type: Number, required: false },

View File

@ -13,7 +13,8 @@ const emailMessageSchema = new Schema(
required: true, required: true,
}, },
objectType: { type: String, required: true }, objectType: { type: String, required: true },
object: { type: Schema.Types.ObjectId, refPath: 'objectType', required: true }, object: { type: Schema.Types.ObjectId, refPath: 'objectType', required: false },
objects: [{ type: Schema.Types.ObjectId, refPath: 'objectType', required: false }],
emailAccount: { emailAccount: {
type: Schema.Types.ObjectId, type: Schema.Types.ObjectId,
ref: 'emailAccount', ref: 'emailAccount',