worldshine-redesign/app/models/client.model.js
2025-04-14 16:29:36 -04:00

74 lines
1.9 KiB
JavaScript

const uniqueValidator = require('mongoose-unique-validator');
module.exports = mongoose => {
var schema = mongoose.Schema(
{
username: {
type: String,
unique: true
},
name: String,
name_cn: String,
email: {
type: String,
unique: true
},
parent_id: String,
password: String,
care_provider: String,
emergency_contact: String,
medicare_number: String,
medicaid_number: String,
pharmacy: String,
birth_date: String,
firstname: String,
lastname: String,
address: String,
address2: String,
phone: String,
mobile_phone: String,
type: String,
avatar: String,
note: String,
language: String,
status: String,
create_by: String,
create_date: Date,
edit_by: String,
edit_date: Date,
password: String,
pharmacy_id: String,
pin: String,
admission_date: String,
home_phone: String,
seating: String,
vehicle_no: String,
caller: String,
roles: [{
type: String
}],
discharge_date: String,
placement: String,
nickname: String,
salt: String,
groups: [{
type: String
}],
tags: [{
type: String
}],
api_token: String,
data: String,
title: String,
private_note: String,
site: Number
},
{ collection: 'client', timestamps: true }
);
schema.method("toJSON", function() {
const { __v, _id, ...object } = this.toObject();
object.id = _id;
return object;
});
const Client = mongoose.model("client", schema);
return Client;
};