import mongoose from "mongoose"; const nodeSchema = new mongoose.Schema( { deviceId: { type: mongoose.Schema.Types.ObjectId, ref: "Device", required: true, index: true, }, /** 8 upper-case hex digits, as reported by the hub. */ serial: { type: String, required: true, uppercase: true, trim: true, match: /^[0-9A-F]{8}$/, }, /** Logical patch ids (Patch `patchId`) this node reports for. */ patches: { type: [String], default: [] }, }, { timestamps: true }, ); nodeSchema.index({ deviceId: 1, serial: 1 }, { unique: true }); export const Node = mongoose.model("Node", nodeSchema);