2025-01-30 12:44:04 +05:30
|
|
|
import mongoose, { Document, Schema } from "mongoose";
|
|
|
|
|
import MainModel from "../connect/mongoose";
|
|
|
|
|
export interface User extends Document {
|
|
|
|
|
userName: String;
|
|
|
|
|
email: String;
|
|
|
|
|
password: String;
|
|
|
|
|
|
|
|
|
|
role: String;
|
|
|
|
|
profilePicture: String;
|
|
|
|
|
isShare:Boolean,
|
|
|
|
|
activeStatus:string
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
const signupschema: Schema = new Schema({
|
|
|
|
|
userName: {
|
|
|
|
|
type: String,
|
|
|
|
|
required: true,
|
|
|
|
|
},
|
|
|
|
|
email: {
|
|
|
|
|
type: String,
|
|
|
|
|
unique: true,
|
|
|
|
|
required: true,
|
|
|
|
|
},
|
|
|
|
|
password: {
|
|
|
|
|
type: String,
|
|
|
|
|
min: 8,
|
|
|
|
|
required: true,
|
|
|
|
|
},
|
|
|
|
|
role: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: "User",
|
|
|
|
|
enum: ["User", "Admin", "Project Manager", "Manager", "Owner"],
|
|
|
|
|
},
|
|
|
|
|
profilePicture: {
|
|
|
|
|
type: String,
|
|
|
|
|
// default: "default-profile-picture.jpg"
|
|
|
|
|
},
|
|
|
|
|
isShare:{
|
|
|
|
|
type:Boolean,
|
|
|
|
|
default:false
|
|
|
|
|
},
|
|
|
|
|
activeStatus:{
|
|
|
|
|
type:String,
|
|
|
|
|
enum: ["online", "offline"],
|
|
|
|
|
default: "offline"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
// const userModel = (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 the model
|
|
|
|
|
// return dbConnection.model("Users", signupschema, "Users");
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
// export default userModel;
|
|
|
|
|
const userModel = (db:string) => {
|
|
|
|
|
return MainModel(db, "Users", signupschema, "Users")
|
|
|
|
|
};
|
2025-01-22 16:59:14 +05:30
|
|
|
export default userModel;
|