{"action":"created","issue":{"url":"https://api.github.com/repos/cozy/cozy-data-system/issues/126","labels_url":"https://api.github.com/repos/cozy/cozy-data-system/issues/126/labels{/name}","comments_url":"https://api.github.com/repos/cozy/cozy-data-system/issues/126/comments","events_url":"https://api.github.com/repos/cozy/cozy-data-system/issues/126/events","html_url":"https://github.com/cozy/cozy-data-system/issues/126","id":59704411,"number":126,"title":"Bulk update","user":{"login":"bnjbvr","id":1180019,"avatar_url":"https://avatars.githubusercontent.com/u/1180019?v=3","gravatar_id":"","url":"https://api.github.com/users/bnjbvr","html_url":"https://github.com/bnjbvr","followers_url":"https://api.github.com/users/bnjbvr/followers","following_url":"https://api.github.com/users/bnjbvr/following{/other_user}","gists_url":"https://api.github.com/users/bnjbvr/gists{/gist_id}","starred_url":"https://api.github.com/users/bnjbvr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bnjbvr/subscriptions","organizations_url":"https://api.github.com/users/bnjbvr/orgs","repos_url":"https://api.github.com/users/bnjbvr/repos","events_url":"https://api.github.com/users/bnjbvr/events{/privacy}","received_events_url":"https://api.github.com/users/bnjbvr/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/cozy/cozy-data-system/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-03-03T20:58:53Z","updated_at":"2015-03-24T08:36:59Z","closed_at":null,"body":"I see there is an end-point for bulk delete, but not for bulk update. However, the db_remove_helper suggests that it shouldn't be too different to do (as a deletion seems to be actually an update, iiuc). Is there any way we could have a bulk update end-point, please?\r\n\r\nHere's an API i imagine:\r\n```\r\nPUT /request/:type/:req_name/update\r\nParam:\r\n  type: the doctype name\r\n  req_name: the name of the request\r\n  Body {\r\n    key: only returns document for this key\r\n    keys: [only returns document for this array of keys]\r\n    limit: number of documents to return\r\n    skip: number of documents to skip\r\n    startKey: only returns document after this key\r\n    endKey: only returns document before this key\r\n    update: [[key, value], [key, value]] or [key, value]\r\n  }\r\n  The body is fully optional.\r\n```\r\n\r\nFor instance, with\r\n```\r\nbody = {\r\n  update: ['date', '1234']\r\n}\r\n```\r\nThen the 'date' field of all values should be updated to '1234'.\r\n\r\n```\r\nbody = {\r\n  update: [['date', '1234'], ['bankAccount', '4321']]\r\n}\r\n```\r\nThen the 'date' field of all values is updated to 1234, and the 'bankAccount' field of all values is updated to 4321.\r\n\r\nNot sure about the naming of `update`, maybe `values` or `replaceBy` would be more adequate."},"comment":{"url":"https://api.github.com/repos/cozy/cozy-data-system/issues/comments/85399425","html_url":"https://github.com/cozy/cozy-data-system/issues/126#issuecomment-85399425","issue_url":"https://api.github.com/repos/cozy/cozy-data-system/issues/126","id":85399425,"user":{"login":"aenario","id":1580287,"avatar_url":"https://avatars.githubusercontent.com/u/1580287?v=3","gravatar_id":"","url":"https://api.github.com/users/aenario","html_url":"https://github.com/aenario","followers_url":"https://api.github.com/users/aenario/followers","following_url":"https://api.github.com/users/aenario/following{/other_user}","gists_url":"https://api.github.com/users/aenario/gists{/gist_id}","starred_url":"https://api.github.com/users/aenario/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aenario/subscriptions","organizations_url":"https://api.github.com/users/aenario/orgs","repos_url":"https://api.github.com/users/aenario/repos","events_url":"https://api.github.com/users/aenario/events{/privacy}","received_events_url":"https://api.github.com/users/aenario/received_events","type":"User","site_admin":false},"created_at":"2015-03-24T08:36:59Z","updated_at":"2015-03-24T08:36:59Z","body":"@jankeromnes , One thing to keep in mind is that cozy has a lot of views in couchdb. So adding many documents slow down the whole cozy. We already had some troubles with emails when importing large accounts. \r\n\r\nSo for your use case of currency, (ie. never changing values). The performance-optimal solution would be to have huge documents with, say, all data for a month and then using views to produce the index you need \r\n\r\n```javascript\r\nfunction(doc){\r\n    if (doc.docType == 'MonthOfCurrencyExchange')\r\n          for (date in doc.dates)\r\n                for (currency in date.currencies)\r\n                       emit(date, currency, value);\r\n```"}}