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

51 lines
1.4 KiB
JavaScript

module.exports = mongoose => {
var editHistorySchema = mongoose.Schema({
employee: String,
date: Date
});
var schema = mongoose.Schema(
{
name: String,
name_original: String,
name_branch: String,
specialty: String,
type: String, // value may be ['doctor', 'pharmacy' or 'other']
color: String,
address: String,
city: String,
state: String,
zipcode: String,
phone: String,
status: String, // value might be ['active', 'inactive']
create_by: String,
create_date: Date,
parent_id: String,
ext_id: String,
category: String,
description: String,
contact: String,
fax: String,
note: String,
data: Object,
edit_by: String,
edit_date: Date,
create_by: String,
create_date: Date,
site: Number,
images: [{
type: String
}],
edit_history: [{
type: editHistorySchema
}],
},
{ collection: 'resource', timestamps: true }
);
schema.method("toJSON", function() {
const { __v, _id, ...object } = this.toObject();
object.id = _id;
return object;
});
const Resource = mongoose.model("resource", schema);
return Resource;
};