I just added Meteor collection2 to my app. And in a file in the server folder I added the code:
Schema = {}
Schema.User = new SimpleSchema(
_id:
type: String
regEx: SimpleSchema.RegEx.Id
username:
type: String
regEx: /^[a-z0-9A-Z_]{3,15}$/
emails:
type: [Object]
optional: true
"emails.$.address":
type: String
regEx: SimpleSchema.RegEx.Email
"emails.$.verified":
type: Boolean
createdAt:
type: Date
)
Meteor.users.attachSchema Schema.User
and it is crashing my app with the error:
W20140907-02:06:32.777(-4)? (STDERR) /Users/Nearpoint/.meteor/packages/meteor-tool/.1.0.25.2ltu8i++os.osx.x86_64+web.browser+web.cordova/meteor-tool-os.osx.x86_64/dev_bundle/lib/node_modules/fibers/future.js:173
W20140907-02:06:32.777(-4)? (STDERR) throw(ex);
W20140907-02:06:32.777(-4)? (STDERR) ^
W20140907-02:06:32.792(-4)? (STDERR) Error: undefined is not allowed by the schema
W20140907-02:06:32.792(-4)? (STDERR) at getErrorObject (packages/aldeed:collection2/collection2.js:489)
W20140907-02:06:32.792(-4)? (STDERR) at doValidate (packages/aldeed:collection2/collection2.js:472)
W20140907-02:06:32.792(-4)? (STDERR) at Meteor.Collection.(anonymous function) [as update] (packages/aldeed:collection2/collection2.js:282)
W20140907-02:06:32.792(-4)? (STDERR) at UserConnections.upsert.$set.ipAddr (packages/mizzao:user-status/status.coffee:94:15)
I am running Meteor 0.9.0. And I am attaching the schema code on the server. I do not know what I am doing wrong. I even tried removing all schema fields except _id and it still did not work.