This repository has been archived on 2026-10-08. You can view files and clone it, but cannot push or open issues or pull requests.
allotment/packages/server/db/models/Node.schema.js

28 lines
671 B
JavaScript

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);