zoneModel updated Structure modified for the API

This commit is contained in:
2025-03-25 12:34:01 +05:30
parent 7a67405d2a
commit 7555eb5c9c
22 changed files with 2074 additions and 118 deletions

View File

@@ -0,0 +1,26 @@
import mongoose, { Document, Schema } from "mongoose";
import MainModel from "../../../connect/mongoose.ts";
const positionSchema = new mongoose.Schema({
x: { type: Number }, // Optional position fields
y: { type: Number },
z: { type: Number },
});
// Define a schema for the individual line
const Vector3 = new mongoose.Schema({
position: { type: positionSchema, required: false }, // Optional position
uuid: { type: String, required: false }, // Optional uuid
});
// Define the main schema
const LineSchema = new mongoose.Schema({
layer: { type: Number, required: true }, // Layer is mandatory
line: { type: [Vector3], required: true }, // Array of line objects
type: { type: String, required: false }, // Optional type
});
// export default lineModel;
const lineModel = (db: string) => {
return MainModel(db, "lines", LineSchema, "lines");
};
export default lineModel;

View File

@@ -0,0 +1,35 @@
import mongoose, { Schema, Document, model } from "mongoose";
import MainModel from "../../../connect/mongoose.ts";
export interface Zone extends Document {
zoneName: string;
// zoneUUID: string;
zonePoints: [];
centerPoints: [];
isArchive: boolean;
createdBy: string;
sceneID: string;
// createdBy: mongoose.Types.ObjectId;
// sceneID: mongoose.Types.ObjectId;
layer: number;
}
const zoneSchema: Schema = new Schema(
{
zoneName: { type: String },
// zoneUUID: { type: String },
createdBy: { type: String },
sceneID: { type: String },
layer: { type: Number },
centerPoints: { type: Array },
zonePoints: { type: Array },
isArchive: { type: Boolean, default: false },
// createdBy: { type: mongoose.Schema.Types.ObjectId, ref: "User" },
// sceneID: { type: mongoose.Schema.Types.ObjectId, ref: "Scene" },
},
{ timestamps: true }
);
const dataModel = (db: any) => {
return MainModel(db, "Zones", zoneSchema, "Zones");
};
export default dataModel;