Skip to content

Instantly share code, notes, and snippets.

@jjhesk
Created April 1, 2016 02:22
Show Gist options
  • Save jjhesk/ca5072b021d5f589129a5bdb097ce537 to your computer and use it in GitHub Desktop.
Save jjhesk/ca5072b021d5f589129a5bdb097ce537 to your computer and use it in GitHub Desktop.
up vote 0 down vote accepted You can control this by specifying the format option, in your case you'd want to set it to false to disable the formatting entirely: FB_event_id: { type: Types.Number, format: false, required: true, initial: true } (I've just updated the docs to specifically mention that you can set this option to false to disable fo…
// models/Event.js
var keystone = require('keystone'),
Types = keystone.Field.Types;
var Event = new keystone.List('Event');
Event.add({
FB_event_id: { type: Types.Number, required: true, initial: true, format: false },
name: { type: Types.Text },
FB_event_name: { type: Types.Text },
description: { type: Types.Textarea },
start_time: { type: Types.Datetime },
end_time: { type: Types.Datetime },
is_date_only: { type: Types.Boolean },
location: { type: Types.Text },
owner_name: { type: Types.Text },
updated_time: { type: Types.Datetime },
venue_name: { type: Types.Text }, // typically given if lat/long data isn't
venue_city : { type: Types.Text },
venue_lat : { type: Types.Number },
venue_long : { type: Types.Number },
venue_state : { type: Types.Text },
venue_street : { type: Types.Text },
venue_zip : { type: Types.Number },
cover_photo: { type: Types.S3File }
});
Event.register();
@jjhesk
Copy link
Author

jjhesk commented Apr 1, 2016

You can control this by specifying the format option, in your case you'd want to set it to false to disable the formatting entirely:

FB_event_id: { type: Types.Number, format: false, required: true, initial: true }
(I've just updated the docs to specifically mention that you can set this option to false to disable formatting altogether)

The ObjectId field type isn't what you're after; these are used by the Relationship field type for linking to other documents in the database, and should only be used to store Mongo ObjectIDs. Any other values result in errors.

Personally though, I often use the String field for ID-type fields, it's just as effective as the Number field and reduces the possibility of unexpected behaviour related to parsing numbers in Javascript.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment