You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a really strange situtation; my schema has a fieldname which is called "type"
type: { type: String, default:"cow" }
the schema is extended by subclasses which override the type field name to change the default value
when I create the document and directly after the cb fires, find it and output the result to console.log, I see "type" and the value "cow" set as its value within the object.
when I access it with the mongo client, there is no field called "type". Getting just the type also doesn't show any document that have that field using this command
db.items.find({},{type:1}).pretty();
in a other script (that executes later), I get the document with mongoose again and there is also no "type" field there either.
Is "type" some special no-no word? My schema worked fine since ages and stopped working recently.
Thanks for your help MongoDB: 2.4.9 Mongoose: 3.8.5
The text was updated successfully, but these errors were encountered:
and was able to fix it by specifically setting type:"cow" when creating the document and not relying on the default schema attribute taking care of that for me. Is the schema's default attribute broken at the moment?
This is something we need to make a bigger deal of in the docs: basically, don't put fields named type in your schema. Mongoose assumes that type means you're trying to set the type of the path in the schema, so { a: { type: { type: String, default:"cow" } } will make mongoose think that you're trying to say that a should be of type { type: String, default:"cow" }. I would recommend you rename type -> kind or something similar.
I have a really strange situtation; my schema has a fieldname which is called "type"
type: { type: String, default:"cow" }
the schema is extended by subclasses which override the type field name to change the default value
when I create the document and directly after the cb fires, find it and output the result to console.log, I see "type" and the value "cow" set as its value within the object.
when I access it with the mongo client, there is no field called "type". Getting just the type also doesn't show any document that have that field using this command
db.items.find({},{type:1}).pretty();
in a other script (that executes later), I get the document with mongoose again and there is also no "type" field there either.
Is "type" some special no-no word? My schema worked fine since ages and stopped working recently.
Thanks for your help MongoDB: 2.4.9 Mongoose: 3.8.5
The text was updated successfully, but these errors were encountered: