Skip to content

Instantly share code, notes, and snippets.

@jaredly
Created September 12, 2013 15:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaredly/6539312 to your computer and use it in GitHub Desktop.
Save jaredly/6539312 to your computer and use it in GitHub Desktop.
I would like to be able to in my mongoose schema specify an object with a variable number of keys whose corresponding values should all conform to a specified schema; similar to the ability to make an array with a variable number of elements who all follow a given schema. Is this possible?
{
"branches": {
"#keyname#": {
"name": String,
"count": Number
}
}
}
// such that the following would be validated
{
"branches": {
"master": {
"name": "Yours",
"count": 4
},
"second": {
"name": "Mine",
"count": 20
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment