All files / koa/app/model partner.js

100% Statements 6/6
100% Branches 0/0
100% Functions 0/0
100% Lines 6/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35    5x 5x 5x           5x                                             5x 5x
'use strict'
 
const mongoose = require('mongoose')
const paginate = require('../../libs/plugins/paginate')
const Schema = mongoose.Schema
// const User = require('./user')
 
/**
 * 经销商
 */
const schema = new Schema({
  name: String, // 经销商公司全名
  contact: String, // 经销商负责人(联系人)
  clazz: { // 类型:1、线上类型;2、线下类型;3、文石自营;
    type: Number,
    default: 1,
  },
  status: { // 状态;1、正常使用;2、停用;3、(伪)删除
    type: Number,
    default: 1,
  },
}, {
  timestamps: {},
  toObject: { virtuals: true },
})
 
// schema.post('findOneAndRemove', function(doc) {
//   User.find({ partner: doc._id }).remove()
//   .then(res => {
//     console.log(`${doc._id} user has removed`);
//   });
// })
 
schema.plugin(paginate);
module.exports = mongoose.model('Partner', schema)