如何设计用于存储每日定时时间的模型?

问题描述

我正在为医生的约会设计一个方案。医生将可以选择更新他/她每月某几天的时间。几个月也没有限制。例如,医生将能够更新未来或本月任何一天的时间。 (仅禁用以前的日期)。前端部分已经完成,但是我无法理解的是如何为其创建mongo模型。当然,我不能将所有月份的日期都存储在模型中。解决此问题的方法是什么? TIA

解决方法

第一种方法,但不适用于您的情况,即一个集合

//doctors
{
   _id: "",appointments: [] // all appointments there
}

第二个会更好,但是NoSql集合中的注释完全取决于您要如何获取数据。两个集合:

//doctors
{
   _id: "SOMETHING",name: "SOMETHING"
}


//appointments
{
   _id: "SOMETHING",doctorId: "",// ref of doctor collection
   appointmentAt: "",appointmentAtMilli: "",}
,

如果是我做过这样的项目,那么我将从 5个收藏集开始:

  • 一个用户的用户(这样您就知道谁做了什么)
  • 一个患者(记录有关患者的所有信息,包括手机号码)
  • 一个医生(这样,您可以在注册时间时显示列表)
  • 一个用于时间注册(包含注册的所有详细信息)
  • 一个用于记录用户所做的一切

这样您就可以回到过去并知道怎么做...永远不要将手指指向犯错的人,而是将其视为发现问题发生的简单方法以及如何您可以防止它再次发生。

每个文档的内容完全取决于您,因为您的工作方式和方式会有所不同

我会考虑以下几行:

// Users
{
  username,hashedPassword,// credentials
  permissions: [],// for when you start using permissions
  active,// never delete data,just set the flag to "false",if,by GDPR rules you need to delete,you can change the name to "DELETED BY GDPR" and still maintain all references
}

// Patients
{
  name,address: { street,street2,city,zipcode,country },// for invoicing proposes
  mobile,// so you send them an SMS 24h before saying their appointment is "tomorrow"
}

// Doctors
{
  name,weekAvailability: [],// days of the week that a doctor is available as they normally work in more than one clinique
  active,you can change the name to "DELETED BY GDPR" and still maintain all references
}

// Logs
{
  action,// for example,"save","add","change"...
  entity,// the collection name that the change happened
  originalEntry,// the full document before changes
  newEntry,// the full document after changes
  timestamp,// the exact time of the change
  user,// ref to users
}

// TimeRegistrations
{
  user,// ref to users
  patient,// ref to patients
  doctor,// ref to doctors
  title,description,appointmentStart,durationInMinutes,}

关于基础架构...创建一个API(REST或GRAPHQL,您最熟悉的API),以便您可以从一开始就将业务逻辑与前端分开

您的前端(可能是React,Angular,VueJs)应调用代理(在前端运行的nodeJs服务器)进行身份验证并调用API,因此您应该在前端做的一切都类似于

fetch('/api/doctors')
  .then(res => res.toJson())
  .then(json => {
    this.doctorsList = json
  })

user的身份验证相同,您可以在其中轻松地使用库为您提供JWT,并轻松维护用户登录并具有正确的权限集