So I am kinda stuck here and wonder if you might be able to help. I decided to get this working from within one of the schemas that you create with the yeoman generator, so that I can have use the adminui to save models easier. After I get this working I will add it to the list.js file within keystone repo. So within the posts model i have:
var keystone = require('keystone'),
mongooseHistory = require('mongoose-history'),
Types = keystone.Field.Types;
var Post = new keystone.List('Post', {
map: { name: 'title' },
autokey: { path: 'slug', from: 'title', unique: true }
});
Post.add({
title: { type: String, required: true },
slug: { type: String, index: true },
state: { type: Types.Select, options: 'draft, published, archived', default: 'draft', index: true },
author: { type: Types.Relationship, ref: 'User', index: true },
publishedDate: { type: Types.Date, index: true },
image: { type: Types.CloudinaryImage },
content: {
brief: { type: Types.Html, wysiwyg: true, height: 150 },
extended: { type: Types.Html, wysiwyg: true, height: 400 }
},
categories: { type: Types.Relationship, ref: 'PostCategory', many: true }
});
Post.schema.virtual('content.full').get(function() {
return this.content.extended || this.content.brief;
});
Post.schema.plugin(mongooseHistory)
Post.defaultColumns = 'title, state|20%, author|20%, publishedDate|20%';
Post.register();
Which should get the mongoose schema from the Post list object and add mongoose history as a plugin. Now when I go to the AdminUI and try to save/update an existing post the application just hangs. No error or anything. I have a couple of guesses here, but dont know how far fetched I am. First, this could be becuase this is a GET request and its not returning anything from the save on <modelName>_history collection because its not returning correctly using a callback. Second, this could be because of other Model.pre('save'...) methods which its getting stuck on. Any suggestions?