Some checks failed
farmcontrol/farmcontrol-api/pipeline/head There was a failure building this commit
26 lines
814 B
JavaScript
26 lines
814 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.index({ name: 'text', website: 'text', email: 'text', phone: 'text', contact: 'text', country: 'text' });
|
|
|
|
courierSchema.virtual('id').get(function () {
|
|
return this._id;
|
|
});
|
|
|
|
courierSchema.set('toJSON', { virtuals: true });
|
|
|
|
export const courierModel = mongoose.model('courier', courierSchema);
|