26 lines
834 B
TypeScript
26 lines
834 B
TypeScript
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 <Q extends mongoose.DocumentQuery<any, any>> (req) {
|
|
db.log(req, this);
|
|
return this;
|
|
}
|
|
|
|
export default mongoose.model<any, mongoose.Model<any, any>>('sample', SampleSchema); |