correctly export user
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import mongoose from "mongoose";
|
import mongoose, { Schema, model, models } from "mongoose";
|
||||||
|
|
||||||
const User = new mongoose.Schema(
|
const UserSchema = new Schema(
|
||||||
{
|
{
|
||||||
name: {
|
name: {
|
||||||
type: String,
|
type: String,
|
||||||
@@ -13,14 +13,12 @@ const User = new mongoose.Schema(
|
|||||||
unique: true,
|
unique: true,
|
||||||
lowercase: true,
|
lowercase: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
role: {
|
role: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
enum: ["patient", "caregiver"],
|
enum: ["patient", "caregiver"],
|
||||||
default: "patient",
|
default: "patient",
|
||||||
},
|
},
|
||||||
|
|
||||||
dateOfBirth: {
|
dateOfBirth: {
|
||||||
type: Date,
|
type: Date,
|
||||||
},
|
},
|
||||||
@@ -43,12 +41,11 @@ const User = new mongoose.Schema(
|
|||||||
relationship: String,
|
relationship: String,
|
||||||
phone: String,
|
phone: String,
|
||||||
},
|
},
|
||||||
|
|
||||||
patients: {
|
patients: {
|
||||||
type: [
|
type: [
|
||||||
{
|
{
|
||||||
patientId: {
|
patientId: {
|
||||||
type: mongoose.Schema.Types.ObjectId,
|
type: Schema.Types.ObjectId,
|
||||||
ref: "User",
|
ref: "User",
|
||||||
},
|
},
|
||||||
relationship: String,
|
relationship: String,
|
||||||
@@ -62,4 +59,4 @@ const User = new mongoose.Schema(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
export default mongoose.models.User || mongoose.model("User", User);
|
export const User = models.User || model("User", UserSchema);
|
||||||
|
|||||||
Reference in New Issue
Block a user