Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let mongoose = require('mongoose')
- let ownerSchema = mongoose.Schema({
- name: String,
- cats: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Cat' }]
- })
- let Cat = require('./Cat')
- ownerSchema.pre('remove', (next) => {
- console.log(this)
- Cat
- .remove({ owner: this._id })
- .exec()
- next()
- })
- module.exports = mongoose.model('Owner', ownerSchema)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement