import mongoose from 'mongoose';
import db from '../db';

const NoteSchema = new mongoose.Schema({
  comment: String,
  sample_references: [{
    sample_id: mongoose.Schema.Types.ObjectId,
    relation: String
  }],
  custom_fields: mongoose.Schema.Types.Mixed
});

// changelog query helper
NoteSchema.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>>('note', NoteSchema);