Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mongoose schema types in KeystoneJS models

var keystone = require('keystone'),
    Types = keystone.Field.Types;

var LeaderboardEntry = new keystone.List('leaderboardEntry', {
  autokey: { path: 'slug', from: 'publicKey playername', unique: false }
});

LeaderboardEntry.add({
  publicKey: { type: String, required: true, noedit: true },
  playername: { type: String, required: true },
  playerid: { type: String },
  points: { type: Number, required: true },
  /*data: { type: Mixed, required: false, unique: false },*/
  publishedDate: { type: Types.Date }
});

The field data needs to be of type Mixed but unfortunately there is not a matching KeystoneJS type.

Any ideas how this can be done within a keystone.List object?

like image 996
Eat at Joes Avatar asked Dec 12 '22 06:12

Eat at Joes


1 Answers

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 });
like image 145
Kelstar Avatar answered Jan 04 '23 19:01

Kelstar