{"action":"created","issue":{"url":"https://api.github.com/repos/typicode/json-server/issues/147","labels_url":"https://api.github.com/repos/typicode/json-server/issues/147/labels{/name}","comments_url":"https://api.github.com/repos/typicode/json-server/issues/147/comments","events_url":"https://api.github.com/repos/typicode/json-server/issues/147/events","html_url":"https://github.com/typicode/json-server/issues/147","id":94466400,"number":147,"title":"POST didn't update data","user":{"login":"isnifer","id":1788245,"avatar_url":"https://avatars.githubusercontent.com/u/1788245?v=3","gravatar_id":"","url":"https://api.github.com/users/isnifer","html_url":"https://github.com/isnifer","followers_url":"https://api.github.com/users/isnifer/followers","following_url":"https://api.github.com/users/isnifer/following{/other_user}","gists_url":"https://api.github.com/users/isnifer/gists{/gist_id}","starred_url":"https://api.github.com/users/isnifer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/isnifer/subscriptions","organizations_url":"https://api.github.com/users/isnifer/orgs","repos_url":"https://api.github.com/users/isnifer/repos","events_url":"https://api.github.com/users/isnifer/events{/privacy}","received_events_url":"https://api.github.com/users/isnifer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-07-11T12:11:10Z","updated_at":"2015-07-16T01:48:28Z","closed_at":null,"body":"Hi, guys!\r\nOn my pet project I have **http://localhost:3000/user** endpoint which returns:\r\n```json\r\n\"user\": {\r\n    \"gold\": 540,\r\n    \"coal\": 12356,\r\n    \"coalSpeed\": 20,\r\n    \"userpic\": \"\",\r\n    \"mail\": 3,\r\n    \"notifications\": 13,\r\n    \"email\": \"john@doe.com\",\r\n    \"username\": \"John\",\r\n    \"notificationSettings\": {\r\n      \"done\": false,\r\n      \"box\": true,\r\n      \"pm\": false,\r\n      \"email\": true\r\n    }\r\n }\r\n```\r\nI tried to make **POST** *http://localhost:3000/user* with data: \r\n```json\r\n{\r\n    \"gold\": 540,\r\n    \"coal\": 12356,\r\n    \"coalSpeed\": 20,\r\n    \"userpic\": \"\",\r\n    \"mail\": 3,\r\n    \"notifications\": 13,\r\n    \"email\": \"john@doe.com\",\r\n    \"username\": \"CHANGE_THIS\",\r\n    \"notificationSettings\": {\r\n      \"done\": false,\r\n      \"box\": true,\r\n      \"pm\": false,\r\n      \"email\": true\r\n    }\r\n }\r\n```\r\n\r\nAnd I getting an error:\r\n```js\r\nTypeError: collection.push is not a function\r\n    at Function.module.exports.insert (/usr/local/lib/node_modules/json-server/node_modules/underscore-db/src/index.js:59:18)\r\n    at baseWrapperValue (/usr/local/lib/node_modules/json-server/node_modules/lodash/index.js:2778:30)\r\n    at LodashWrapper.wrapperValue (/usr/local/lib/node_modules/json-server/node_modules/lodash/index.js:6104:14)\r\n    at LodashWrapper._.value (/usr/local/lib/node_modules/json-server/node_modules/lowdb/src/index.js:39:21)\r\n    at LodashWrapper.<anonymous> (/usr/local/lib/node_modules/json-server/node_modules/lowdb/src/index.js:18:35)\r\n    at LodashWrapper.insert (/usr/local/lib/node_modules/json-server/node_modules/lodash/index.js:3337:35)\r\n    at create (/usr/local/lib/node_modules/json-server/src/router.js:202:8)\r\n    at Layer.handle [as handle_request] (/usr/local/lib/node_modules/json-server/node_modules/express/lib/router/layer.js:95:5)\r\n    at next (/usr/local/lib/node_modules/json-server/node_modules/express/lib/router/route.js:131:13)\r\n    at next (/usr/local/lib/node_modules/json-server/node_modules/express/lib/router/route.js:125:14)\r\n```\r\n\r\nI found this method and understand that **collection** argument in my case is not an Array.\r\nWhat I do wrong? I need to update collection."},"comment":{"url":"https://api.github.com/repos/typicode/json-server/issues/comments/121798535","html_url":"https://github.com/typicode/json-server/issues/147#issuecomment-121798535","issue_url":"https://api.github.com/repos/typicode/json-server/issues/147","id":121798535,"user":{"login":"typicode","id":5502029,"avatar_url":"https://avatars.githubusercontent.com/u/5502029?v=3","gravatar_id":"","url":"https://api.github.com/users/typicode","html_url":"https://github.com/typicode","followers_url":"https://api.github.com/users/typicode/followers","following_url":"https://api.github.com/users/typicode/following{/other_user}","gists_url":"https://api.github.com/users/typicode/gists{/gist_id}","starred_url":"https://api.github.com/users/typicode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/typicode/subscriptions","organizations_url":"https://api.github.com/users/typicode/orgs","repos_url":"https://api.github.com/users/typicode/repos","events_url":"https://api.github.com/users/typicode/events{/privacy}","received_events_url":"https://api.github.com/users/typicode/received_events","type":"User","site_admin":false},"created_at":"2015-07-16T01:48:28Z","updated_at":"2015-07-16T01:48:28Z","body":"Hi @isnifer,\r\n\r\nSorry for the delay, you need to use an array and a rewrite rule for singular resources.\r\n\r\n`db.json`\r\n\r\n```json\r\n{\r\n  \"users\": [{\r\n    \"id\": 1,\r\n    \"gold\": 540,\r\n```\r\n\r\n`routes.json`\r\n\r\n```json\r\n{\r\n  \"/user\": \"/users/1\"\r\n}\r\n```\r\n\r\n```\r\njson-server db.json -r routes.json\r\n```"}}