{"action":"created","issue":{"url":"https://api.github.com/repos/LearnBoost/mongoose/issues/2376","labels_url":"https://api.github.com/repos/LearnBoost/mongoose/issues/2376/labels{/name}","comments_url":"https://api.github.com/repos/LearnBoost/mongoose/issues/2376/comments","events_url":"https://api.github.com/repos/LearnBoost/mongoose/issues/2376/events","html_url":"https://github.com/LearnBoost/mongoose/issues/2376","id":45768040,"number":2376,"title":"Ability to add object-arrays to schema","user":{"login":"grabbou","id":2464966,"avatar_url":"https://avatars.githubusercontent.com/u/2464966?v=3","gravatar_id":"","url":"https://api.github.com/users/grabbou","html_url":"https://github.com/grabbou","followers_url":"https://api.github.com/users/grabbou/followers","following_url":"https://api.github.com/users/grabbou/following{/other_user}","gists_url":"https://api.github.com/users/grabbou/gists{/gist_id}","starred_url":"https://api.github.com/users/grabbou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grabbou/subscriptions","organizations_url":"https://api.github.com/users/grabbou/orgs","repos_url":"https://api.github.com/users/grabbou/repos","events_url":"https://api.github.com/users/grabbou/events{/privacy}","received_events_url":"https://api.github.com/users/grabbou/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2014-10-14T16:02:54Z","updated_at":"2015-03-07T00:38:00Z","closed_at":null,"body":"It'd be useful to have the ability to force specific values and keys on all properties inside your object.\r\n\r\nIn my use-case, I have `provider` property attached to my main schema that contains multiple providers in it (Facebook, google+ and other passport goodies). The problem is that I don't want to use arrays as dot noted access matters here.\r\n\r\nHere's the current snippet of code:\r\n```js\r\nnew Schema({\r\n    provider: {\r\n        facebook: {\r\n            accessToken: String,\r\n            refreshToken: String,\r\n            id: String,\r\n            displayName: String\r\n        },\r\n        instagram: {\r\n            accessToken: String,\r\n            refreshToken: String,\r\n            id: String,\r\n            displayName: String\r\n        },\r\n        // and so on....\r\n   }\r\n});\r\n```\r\n\r\nIt'd be super handy to do something like:\r\n```js\r\nnew Schema({\r\n    provider: {\r\n        [validation-rule-for-key]: {\r\n            accessToken: String,\r\n            refreshToken: String,\r\n            id: String,\r\n            displayName: String\r\n        }\r\n   }\r\n});\r\n```\r\n\r\nKind of similar to #681, but that issue is only speaking about validation for keys, not about ability to have multiple properties. Validation of the key is actually not that important for me actually, can be anything. Should be faster to develop then.\r\n\r\nWhat you think?"},"comment":{"url":"https://api.github.com/repos/LearnBoost/mongoose/issues/comments/77661966","html_url":"https://github.com/LearnBoost/mongoose/issues/2376#issuecomment-77661966","issue_url":"https://api.github.com/repos/LearnBoost/mongoose/issues/2376","id":77661966,"user":{"login":"rcuddy","id":4494839,"avatar_url":"https://avatars.githubusercontent.com/u/4494839?v=3","gravatar_id":"","url":"https://api.github.com/users/rcuddy","html_url":"https://github.com/rcuddy","followers_url":"https://api.github.com/users/rcuddy/followers","following_url":"https://api.github.com/users/rcuddy/following{/other_user}","gists_url":"https://api.github.com/users/rcuddy/gists{/gist_id}","starred_url":"https://api.github.com/users/rcuddy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rcuddy/subscriptions","organizations_url":"https://api.github.com/users/rcuddy/orgs","repos_url":"https://api.github.com/users/rcuddy/repos","events_url":"https://api.github.com/users/rcuddy/events{/privacy}","received_events_url":"https://api.github.com/users/rcuddy/received_events","type":"User","site_admin":false},"created_at":"2015-03-07T00:38:00Z","updated_at":"2015-03-07T00:38:00Z","body":"Not sure how to upvote this as a \"yes please\" feature, but, 'yes please'. I'm wanting to store custom form fields in one document and their values in another, and being able to look up values[field._id.toString()] is much faster than having to loop a values array and look for the value with matching fieldId property."}}