Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var mongoose = require('mongoose');
- var Schema = mongoose.Schema;triggers
- var User = require('./UserModel');
- var PostSchema = new Schema({
- 'title' : String,
- 'content' : String,
- 'date' : Date,
- 'tags' : String,
- 'userID' : {
- type: Schema.Types.ObjectId,
- ref: 'User'
- }
- });
- PostSchema.post('save', function (doc) {
- User.findById(doc.userID,function (err, doc) {
- //here you would normally do doc.set and doc.save right? but there's no response object
- });
- });
- module.exports = mongoose.model('Post', PostSchema);
Add Comment
Please, Sign In to add comment