2025-03-31 18:30:14 +05:30
|
|
|
import mongoose, { Document, Schema } from "mongoose";
|
|
|
|
|
import MainModel from "../../connect/mongoose.ts";
|
2025-01-30 12:44:04 +05:30
|
|
|
// Interface for TypeScript with PascalCase
|
|
|
|
|
export interface environment extends Document {
|
|
|
|
|
userId: string;
|
2025-03-31 18:30:14 +05:30
|
|
|
roofVisibility: boolean;
|
|
|
|
|
wallVisibility: boolean;
|
|
|
|
|
renderDistance: number;
|
|
|
|
|
shadowVisibility: boolean;
|
|
|
|
|
limitDistance: boolean;
|
2025-01-30 12:44:04 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Define the Mongoose Schema
|
|
|
|
|
const environmentSchema: Schema = new Schema({
|
|
|
|
|
userId: { type: String, unique: true },
|
2025-03-31 18:30:14 +05:30
|
|
|
roofVisibility: { type: Boolean, default: false },
|
|
|
|
|
wallVisibility: { type: Boolean, default: false },
|
|
|
|
|
shadowVisibility: { type: Boolean, default: false },
|
|
|
|
|
renderDistance: { type: Number, default: false },
|
|
|
|
|
limitDistance: { type: Boolean, default: true },
|
2025-01-30 12:44:04 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Model for MongoDB collection
|
|
|
|
|
// const cameraModel = model<Camera>("Camera", cameraSchema);
|
|
|
|
|
|
|
|
|
|
// export default cameraModel;
|
|
|
|
|
// const environmentModel = (db: string) => {
|
|
|
|
|
// const mongoUrl = process.env.MONGO_URI || '';
|
|
|
|
|
// if (!mongoUrl) {
|
|
|
|
|
// throw new Error('MONGO_URI environment variable is not set');
|
|
|
|
|
// }
|
|
|
|
|
// // Connect to the database
|
|
|
|
|
// const dbConnection = mongoose.createConnection(mongoUrl, {
|
|
|
|
|
// dbName: db, // Specify the database name here
|
|
|
|
|
// serverSelectionTimeoutMS: 30000,
|
|
|
|
|
// });
|
|
|
|
|
// return dbConnection.model<environment>('environments', environmentSchema,`environments`);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// export default environmentModel;
|
2025-03-31 18:30:14 +05:30
|
|
|
const environmentModel = (db: string) => {
|
|
|
|
|
return MainModel(db, "environments", environmentSchema, "environments");
|
2025-01-30 12:44:04 +05:30
|
|
|
};
|
2025-03-31 18:30:14 +05:30
|
|
|
export default environmentModel;
|