SHARE
TWEET

Untitled

a guest Oct 28th, 2016 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let mongoose = require('mongoose')
  2. let ownerSchema = mongoose.Schema({
  3.   name: String,
  4.   cats: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Cat' }]
  5. })
  6. let Cat = require('./Cat')
  7.  
  8. ownerSchema.pre('remove', (next) => {
  9.   console.log(this)
  10.   Cat
  11.     .remove({ owner: this._id })
  12.     .exec()
  13.  
  14.   next()
  15. })
  16.  
  17. module.exports = mongoose.model('Owner', ownerSchema)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top