Mongoose schema types in KeystoneJS models Mongoose schema types in KeystoneJS models mongoose mongoose

Mongoose schema types in KeystoneJS models


A while back I ran into the same issue and ran across this Twitter post .. It won't show up in the admin UI, but it's possible to add a Mongoose field type this way.

Add this after your code above:

LeaderboardEntry.schema.add({ data: mongoose.Schema.Types.Mixed });


You can define like this in your model file

var keystone = require('keystone');var mongoose = require('mongoose'); // "npm i --save mongoose" of coursevar Types = keystone.Field.Types;var FBEntry = new keystone.List('FBEntry');FBEntry.add({    type: { type: String, index: true },    // data: mongoose.Schema.Types.Mixed    <--- define overhere will throw exception});FBEntry.schema.add({ data: mongoose.Schema.Types.Mixed }); // you should define outside .add()FBEntry.defaultColumns = 'type, data';FBEntry.register();