I am using Mongoose + CoffeeScript and when I try to add embedded documents to my Schema, the code is wrongly converted.
e.g:
AccountSchema = new Schema # Companhia
name : String
users : [UserSchema]
custphones : [CustphoneSchema]
becomes
AccountSchema = new Schema({
name: String({
users: [UserSchema],
custphones: [CustphoneSchema]
})
});
and should have become
AccountSchema = new Schema({
name: String,
users: [UserSchema],
custphones: [CustphoneSchema]
});
Why is this happening?
Thanks
Did you check that the indentations are consistent in their use of tabs and spaces? This is a common problem when whitespace is part of the syntax.
To get your your particular (broken) output, you probably indented with tab on name, and spaces on users and custphones.
Your code compiles correctly on my machine. What you still can do is to add commas to the hash entries to help coffee script compile your code:
AccountSchema = new Schema # Companhia
name : String,
users : [UserSchema],
custphones : [CustphoneSchema]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With