mongoose - Keystone.js Number fieldtype tweak -
i'm trying add together id-like column keystone events
model. have following
// 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 }, 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 info 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();
in admin ui though see 270,385,519,824,039
fb_event_id
more of quantity number rather identification number. how can remove these commas? utilize different fieldtype? there anyway access mongoose objectid
field type? http://mongoosejs.com/docs/schematypes.html perfect think.
this purely aesthetic issue (semantic perhaps). id stored without commas in database.
http://keystonejs.com/docs/database/#fieldtypes-number
you can command specifying format
option, in case you'd want set false
disable formatting entirely:
fb_event_id: { type: types.number, format: false, required: true, initial: true }
(i've updated docs mention can set alternative false
disable formatting altogether)
the objectid
field type isn't you're after; these used relationship
field type linking other documents in database, , should used store mongo objectids. other values result in errors.
personally though, utilize string
field id-type fields, it's effective number
field , reduces possibility of unexpected behaviour related parsing numbers in javascript.
mongoose keystone.js
No comments:
Post a Comment