I am newbie in Meteor ,I want to use an embedded document in my User collection. I am using simple schema added by collection2 package. But as i define the embedded document as i simply defined in one of my Node.js project and that was running successfully without any errors, but as i defined the same in my Meteor project inside User collection it throws an error i.e
/home/parveen/.meteor/packages/meteor-tool/.1.3.2_4.10vjklo++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:267
W20160604-23:22:34.819(5.5)? (STDERR) throw(ex);
W20160604-23:22:34.819(5.5)? (STDERR) ^
W20160604-23:22:34.941(5.5)? (STDERR) Error: Invalid definition for location field.
W20160604-23:22:34.941(5.5)? (STDERR) at packages/aldeed_simple-schema/simple-schema.js:457:1
W20160604-23:22:34.941(5.5)? (STDERR) at Function._.each._.forEach (packages/underscore/underscore.js:113:1)
W20160604-23:22:34.941(5.5)? (STDERR) at [object Object].SimpleSchema (packages/aldeed_simple-schema/simple-schema.js:454:1)
W20160604-23:22:34.941(5.5)? (STDERR) at meteorInstall.collections.Users.js (collections/Users.js:11:14)
W20160604-23:22:34.942(5.5)? (STDERR) at fileEvaluate (packages/modules-runtime/.npm/package/node_modules/install/install.js:141:1)
W20160604-23:22:34.942(5.5)? (STDERR) at require (packages/modules-runtime/.npm/package/node_modules/install/install.js:75:1)
W20160604-23:22:34.942(5.5)? (STDERR) at /home/parveen/differentialImaging/.meteor/local/build/programs/server/app/app.js:957:1
W20160604-23:22:34.942(5.5)? (STDERR) at /home/parveen/differentialImaging/.meteor/local/build/programs/server/boot.js:283:10
W20160604-23:22:34.942(5.5)? (STDERR) at Array.forEach (native)
W20160604-23:22:34.942(5.5)? (STDERR) at Function._.each._.forEach (/home/parveen/.meteor/packages/meteor-tool/.1.3.2_4.10vjklo++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
=> Exited with code: 8
=> Your application is crashing. Waiting for file change.
My schema is as follows:-
UserSchema = new SimpleSchema({
name:{
type: String,
trim: true,
optional: true
},
email:{
type:String,
trim: true,
optional: true
},
password:{
type:String,
trim: true,
optional: true
},
location: {
latitude: {
type: Number,
default: 0,
required: false
},
longitude: {
type: Number,
default: 0,
required: false
},
state: {
type: String,
default: '',
requried: false,
trim: true
},
city: {
type: String,
default: '',
requried: false,
trim: true
}
},
createdAt:{
type:Date,
label:"Created At",
autoValue:function(){
return new Date();
}
}
});
Users.attachSchema(UserSchema);
As you can see its given an error at location field on which i am using embedded document.
Please tell me how we can achieve the same in Meteor, or i am doing something wrong here. Is there any other schema i need to use rather than simple schema or we can achieve the same via Simple schema as well.
Any help suggestion would be appreciated Thanks