37 lines
1002 B
TypeScript
37 lines
1002 B
TypeScript
// src/models/drone-registration.ts
|
|
// Copyright (C) 2026 Robert Colbert <rob.colbert@openplatform.us>
|
|
// All Rights Reserved
|
|
|
|
import { Schema, model } from "mongoose";
|
|
import { DroneStatus, IDroneRegistration } from "@gadget/api";
|
|
|
|
export const DroneRegistrationSchema = new Schema<IDroneRegistration>({
|
|
createdAt: { type: Date, required: true },
|
|
updatedAt: { type: Date, required: false },
|
|
user: { type: Schema.Types.ObjectId, ref: "User", required: true },
|
|
hostname: { type: String, required: true },
|
|
workspaceDir: { type: String, required: true },
|
|
status: {
|
|
type: String,
|
|
enum: DroneStatus,
|
|
default: DroneStatus.Starting,
|
|
required: true,
|
|
},
|
|
currentJobId: { type: String, required: false },
|
|
});
|
|
|
|
DroneRegistrationSchema.index({
|
|
user: 1,
|
|
status: 1,
|
|
});
|
|
|
|
export const DroneRegistration = model<IDroneRegistration>(
|
|
"DroneRegistration",
|
|
DroneRegistrationSchema,
|
|
);
|
|
export default DroneRegistration;
|
|
|
|
(async () => {
|
|
await DroneRegistration.syncIndexes();
|
|
})();
|