Using arrays with custom schema types

175 views
Skip to first unread message

Yashua Savage

unread,
Feb 27, 2013, 11:55:58 AM2/27/13
to mongoo...@googlegroups.com
Weird... though I posted this before - forgive the double posting if so.


Basically I'm trying to use a custom schema type as an array such as:

var s = new Schema({
  links: {
    type: [Url]
  }
});


However no validation ever occurs when doing such as thing.  is it possible to do so? Or would I have to rewrite it with a custom type as:

var s = new Schema({
  links: {
    type: UrlArray
  }
});


Aaron Heckmann

unread,
Feb 27, 2013, 8:23:05 PM2/27/13
to mongoo...@googlegroups.com
Unless the Url is a subdocument, validation will not get triggered currently (there is a ticket open somewhere to support richer types). The work-around is to define validation on the array:



--
--
http://mongoosejs.com - docs
http://plugins.mongoosejs.com - plugins search
http://github.com/learnboost/mongoose - source code
http://mongoosejs.tumblr.com/ - production examples
 
You received this message because you are subscribed to the Google
Groups "Mongoose Node.JS ORM" group.
To post to this group, send email to mongoo...@googlegroups.com
To unsubscribe from this group, send email to
mongoose-orm...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/mongoose-orm?hl=en
---
You received this message because you are subscribed to the Google Groups "Mongoose Node.JS ODM" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongoose-orm...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Aaron


Reply all
Reply to author
Forward
0 new messages