Permalink
Browse files

update README with schema 'type' use

  • Loading branch information...
1 parent 73e7bd1 commit c974aa2d68b9f38b458cc5990e0be9a802a7ca7c @aheckmann aheckmann committed Aug 5, 2011
Showing with 23 additions and 0 deletions.
  1. +23 −0 README.md
View
@@ -316,6 +316,29 @@ new values to `next`:
})
```
+### Schema gotcha
+
+`type`, when used in a schema has special meaning within Mongoose. If your
+schema requires using `type` as a nested property you must use object notation:
+
+``` javascript
+new Schema({
+ broken: { type: Boolean }
+ , asset : {
+ name: String
+ , type: String // uh oh, it broke. asset will be interpreted as String
+ }
+});
+
+new Schema({
+ works: { type: Boolean }
+ , asset : {
+ name: String
+ , type: { type: String } // works. asset is an object with a type property
+ }
+});
+```
+
## API docs
You can find the [Dox](http://github.com/visionmedia/dox) generated API docs at

0 comments on commit c974aa2

Please sign in to comment.