{"action":"opened","issue":{"url":"https://api.github.com/repos/vdemedes/mongorito/issues/51","labels_url":"https://api.github.com/repos/vdemedes/mongorito/issues/51/labels{/name}","comments_url":"https://api.github.com/repos/vdemedes/mongorito/issues/51/comments","events_url":"https://api.github.com/repos/vdemedes/mongorito/issues/51/events","html_url":"https://github.com/vdemedes/mongorito/issues/51","id":97544723,"number":51,"title":"Equivalent of $push ?","user":{"login":"HereThereBeMonsters","id":4921697,"avatar_url":"https://avatars.githubusercontent.com/u/4921697?v=3","gravatar_id":"","url":"https://api.github.com/users/HereThereBeMonsters","html_url":"https://github.com/HereThereBeMonsters","followers_url":"https://api.github.com/users/HereThereBeMonsters/followers","following_url":"https://api.github.com/users/HereThereBeMonsters/following{/other_user}","gists_url":"https://api.github.com/users/HereThereBeMonsters/gists{/gist_id}","starred_url":"https://api.github.com/users/HereThereBeMonsters/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HereThereBeMonsters/subscriptions","organizations_url":"https://api.github.com/users/HereThereBeMonsters/orgs","repos_url":"https://api.github.com/users/HereThereBeMonsters/repos","events_url":"https://api.github.com/users/HereThereBeMonsters/events{/privacy}","received_events_url":"https://api.github.com/users/HereThereBeMonsters/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-07-27T20:09:31Z","updated_at":"2015-07-27T20:09:31Z","closed_at":null,"body":"Hi,\r\n\r\nI am quite new to node AND mongo, please be patient :)\r\n\r\nI am currently in the process of rewriting a webapp's persistence using mongorito. So far I like it quite a lot.\r\n\r\nBut I need to do things like add comments to an issue, or add followers. These are represented in my schema as arrays of ids or arrays of objects inside the main document.\r\n\r\nIt used to be implemented using the native mongo `$push` keywords, like this: \r\n\r\n    db.discussion.update(\r\n        { 'discussion_id': discussion_id },\r\n        { '$push': { 'comments': {\r\n            'posted': datetime.utcnow(),\r\n            'author': author_info,\r\n            'text': comment_text } } } );\r\n\r\nUsing Mongorito, I could not find an equivalent to this construct. The workaround is to load the whole parent (`discussion` in this example), add the comment or follower, and finally save the whole object again. This is not optimal. 2 DB hits instead of one, and potentially loading a big object just to add a single id in an array.\r\n\r\nWhat would you recommend instead ? Is there support for this kind of operations built into Mongorito ?\r\n\r\n"}}