Refactor deviceInfo schema in host management to simplify structure
All checks were successful
farmcontrol/farmcontrol-api/pipeline/head This commit looks good
All checks were successful
farmcontrol/farmcontrol-api/pipeline/head This commit looks good
This commit modifies the `deviceInfo` schema by removing unused fields such as `uptime`, `memory`, and `network`, streamlining the schema for better clarity and performance. The `deviceInfo` property in the `hostSchema` is updated to directly reference the `deviceInfoSchema`, enhancing code readability and maintainability.
This commit is contained in:
parent
6393ed5e3e
commit
ec5783acd8
@ -10,20 +10,12 @@ const deviceInfoSchema = new mongoose.Schema(
|
|||||||
release: { type: String },
|
release: { type: String },
|
||||||
arch: { type: String },
|
arch: { type: String },
|
||||||
hostname: { type: String },
|
hostname: { type: String },
|
||||||
uptime: { type: Number },
|
|
||||||
},
|
},
|
||||||
cpu: {
|
cpu: {
|
||||||
cores: { type: Number },
|
cores: { type: Number },
|
||||||
model: { type: String },
|
model: { type: String },
|
||||||
speedMHz: { type: Number },
|
speedMHz: { type: Number },
|
||||||
},
|
},
|
||||||
memory: {
|
|
||||||
totalGB: { type: String }, // stored as string from .toFixed(2), could also use Number
|
|
||||||
freeGB: { type: String },
|
|
||||||
},
|
|
||||||
network: {
|
|
||||||
type: mongoose.Schema.Types.Mixed, // since it's an object with dynamic interface names
|
|
||||||
},
|
|
||||||
user: {
|
user: {
|
||||||
uid: { type: Number },
|
uid: { type: Number },
|
||||||
gid: { type: Number },
|
gid: { type: Number },
|
||||||
@ -33,8 +25,6 @@ const deviceInfoSchema = new mongoose.Schema(
|
|||||||
},
|
},
|
||||||
process: {
|
process: {
|
||||||
nodeVersion: { type: String },
|
nodeVersion: { type: String },
|
||||||
pid: { type: Number },
|
|
||||||
cwd: { type: String },
|
|
||||||
execPath: { type: String },
|
execPath: { type: String },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -55,7 +45,7 @@ const hostSchema = new mongoose.Schema(
|
|||||||
active: { required: true, type: Boolean, default: true },
|
active: { required: true, type: Boolean, default: true },
|
||||||
connectedAt: { required: false, type: Date },
|
connectedAt: { required: false, type: Date },
|
||||||
authCode: { type: { required: false, type: String } },
|
authCode: { type: { required: false, type: String } },
|
||||||
deviceInfo: { deviceInfoSchema },
|
deviceInfo: deviceInfoSchema,
|
||||||
otp: { type: { required: false, type: String } },
|
otp: { type: { required: false, type: String } },
|
||||||
otpExpiresAt: { required: false, type: Date },
|
otpExpiresAt: { required: false, type: Date },
|
||||||
files: [{ type: mongoose.Schema.Types.ObjectId, ref: 'file' }],
|
files: [{ type: mongoose.Schema.Types.ObjectId, ref: 'file' }],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user