import mongoose from 'mongoose'; import MaterialModel from './material'; import NoteModel from './note'; import UserModel from './user'; import db from '../db'; const SampleSchema = new mongoose.Schema({ number: {type: String, index: {unique: true}}, type: String, color: String, batch: String, condition: mongoose.Schema.Types.Mixed, material_id: {type: mongoose.Schema.Types.ObjectId, ref: MaterialModel}, note_id: {type: mongoose.Schema.Types.ObjectId, ref: NoteModel}, user_id: {type: mongoose.Schema.Types.ObjectId, ref: UserModel}, status: Number }, {minimize: false}); // changelog query helper SampleSchema.query.log = function > (req) { db.log(req, this); return this; } export default mongoose.model>('sample', SampleSchema);