Initial
This commit is contained in:
38
src/shared/model/environments/environments-Model.ts
Normal file
38
src/shared/model/environments/environments-Model.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import mongoose, { Document, Schema } from 'mongoose';
|
||||
import MainModel from '../../connect/mongoose';
|
||||
// Interface for TypeScript with PascalCase
|
||||
export interface environment extends Document {
|
||||
userId: string;
|
||||
roofVisibility:boolean
|
||||
wallVisibility:boolean
|
||||
}
|
||||
|
||||
// Define the Mongoose Schema
|
||||
const environmentSchema: Schema = new Schema({
|
||||
userId: { type: String, unique: true },
|
||||
roofVisibility: { type: Boolean ,default:false},
|
||||
wallVisibility: { type: Boolean ,default:false},
|
||||
});
|
||||
|
||||
// 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;
|
||||
const environmentModel = (db:string) => {
|
||||
return MainModel(db, "environments", environmentSchema, "environments")
|
||||
};
|
||||
export default environmentModel;
|
||||
Reference in New Issue
Block a user