24 lines
693 B
JavaScript
24 lines
693 B
JavaScript
import mongoose from 'mongoose';
|
|
import { generateId } from '../../utils.js';
|
|
|
|
const courierSchema = new mongoose.Schema(
|
|
{
|
|
_reference: { type: String, default: () => generateId()() },
|
|
name: { required: true, type: String },
|
|
website: { required: false, type: String },
|
|
email: { required: false, type: String },
|
|
phone: { required: false, type: String },
|
|
contact: { required: false, type: String },
|
|
country: { required: false, type: String },
|
|
},
|
|
{ timestamps: true }
|
|
);
|
|
|
|
courierSchema.virtual('id').get(function () {
|
|
return this._id;
|
|
});
|
|
|
|
courierSchema.set('toJSON', { virtuals: true });
|
|
|
|
export const courierModel = mongoose.model('courier', courierSchema);
|