{"action":"created","issue":{"url":"https://api.github.com/repos/balderdashy/sails/issues/4556","repository_url":"https://api.github.com/repos/balderdashy/sails","labels_url":"https://api.github.com/repos/balderdashy/sails/issues/4556/labels{/name}","comments_url":"https://api.github.com/repos/balderdashy/sails/issues/4556/comments","events_url":"https://api.github.com/repos/balderdashy/sails/issues/4556/events","html_url":"https://github.com/balderdashy/sails/issues/4556","id":387651447,"node_id":"MDU6SXNzdWUzODc2NTE0NDc=","number":4556,"title":"sum() with mongo adapter","user":{"login":"wizmea","id":8898105,"node_id":"MDQ6VXNlcjg4OTgxMDU=","avatar_url":"https://avatars0.githubusercontent.com/u/8898105?v=4","gravatar_id":"","url":"https://api.github.com/users/wizmea","html_url":"https://github.com/wizmea","followers_url":"https://api.github.com/users/wizmea/followers","following_url":"https://api.github.com/users/wizmea/following{/other_user}","gists_url":"https://api.github.com/users/wizmea/gists{/gist_id}","starred_url":"https://api.github.com/users/wizmea/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wizmea/subscriptions","organizations_url":"https://api.github.com/users/wizmea/orgs","repos_url":"https://api.github.com/users/wizmea/repos","events_url":"https://api.github.com/users/wizmea/events{/privacy}","received_events_url":"https://api.github.com/users/wizmea/received_events","type":"User","site_admin":false},"labels":[{"id":335017164,"node_id":"MDU6TGFiZWwzMzUwMTcxNjQ=","url":"https://api.github.com/repos/balderdashy/sails/labels/Needs%20cleanup","name":"Needs cleanup","color":"c2e0c6","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-12-05T08:51:42Z","updated_at":"2018-12-05T08:51:59Z","closed_at":null,"author_association":"NONE","body":"<!--\r\n### BEGIN VERSION INFO ###\r\n-->\r\n\r\n**Sails version**: 1.1.0\r\n**Node version**:v10.5.0\r\n**NPM version**:\r\n**DB adapter name**: sails-mongo\r\n**DB adapter version**: 1.0.1\r\n\r\n<!--\r\n### END VERSION INFO ###\r\n\r\n<!--\r\n###QUERY ###\r\n-->\r\n\r\n<!--\r\n**Query**\r\n`amount = await RdvConsultation.sum('cost').where({\r\n        f_etablishment: data.id,\r\n        payStatus: \"PAID\",\r\n        createdAt: {'>=': firstDay, '<=': lastDay}\r\n      })`\r\n-->\r\n\r\n**Query**\r\n`amount = await RdvConsultation.sum('cost').where({\r\n        f_etablishment: data.id,\r\n        payStatus: \"PAID\",\r\n        createdAt: {'>=': firstDay, '<=': lastDay}\r\n      })`\r\n**Error**\r\n{ AdapterError: Unexpected error from database adapter: Internal error occurred while running `sumRecords`.  Got non-Error: { MongoError: The 'cursor' option is required, except for aggregate with the explain argument\r\n    at Function.MongoError.create (/Users/arcadius/taf/web/opensi/gomedical/gomedical-backend/node_modules/sails-mongo/node_modules/mongodb-core/lib/error.js:31:11)\r\n    at /Users/arcadius/taf/web/opensi/gomedical/gomedical-backend/node_modules/sails-mongo/node_modules/mongodb-core/lib/connection/pool.js:489:72\r\n    at authenticateStragglers (/Users/arcadius/taf/web/opensi/gomedical/gomedical-backend/node_modules/sails-mongo/node_modules/mongodb-core/lib/connection/pool.js:435:16)\r\n    at Connection.messageHandler (/Users/arcadius/taf/web/opensi/gomedical/gomedical-backend/node_modules/sails-mongo/node_modules/mongodb-core/lib/connection/pool.js:469:5)\r\n    at Socket.<anonymous> (/Users/arcadius/taf/web/opensi/gomedical/gomedical-backend/node_modules/sails-mongo/node_modules/mongodb-core/lib/connection/connection.js:321:22)\r\n    at Socket.emit (events.js:182:13)\r\n    at Socket.EventEmitter.emit (domain.js:442:20)\r\n    at addChunk (_stream_readable.js:283:12)\r\n    at readableAddChunk (_stream_readable.js:264:11)\r\n    at Socket.Readable.push (_stream_readable.js:219:10)\r\n    at TCP.onread (net.js:635:20)\r\n  name: 'MongoError',\r\n  message:\r\n   'The \\'cursor\\' option is required, except for aggregate with the explain argument',\r\n  ok: 0,\r\n  errmsg:\r\n   'The \\'cursor\\' option is required, except for aggregate with the explain argument',\r\n  code: 9,\r\n  codeName: 'FailedToParse' }\r\n\r\nIf you are the maintainer of \"sumRecords\", then you can change its implementation to solve the problem (Most of the time, the solution is just to throw an actual Error instance instead.  Alternatively, if the goal was to indicate a particular exception, you could throw any of the special, reserved \"exit signals\"-- e.g. the code name of any of your defined exits besides \"error\" or \"success\").  Otherwise, please file a bug report with the maintainer, or fork your own copy and fix that.\r\n"},"comment":{"url":"https://api.github.com/repos/balderdashy/sails/issues/comments/444407071","html_url":"https://github.com/balderdashy/sails/issues/4556#issuecomment-444407071","issue_url":"https://api.github.com/repos/balderdashy/sails/issues/4556","id":444407071,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0NDQwNzA3MQ==","user":{"login":"sailsbot","id":14700466,"node_id":"MDQ6VXNlcjE0NzAwNDY2","avatar_url":"https://avatars2.githubusercontent.com/u/14700466?v=4","gravatar_id":"","url":"https://api.github.com/users/sailsbot","html_url":"https://github.com/sailsbot","followers_url":"https://api.github.com/users/sailsbot/followers","following_url":"https://api.github.com/users/sailsbot/following{/other_user}","gists_url":"https://api.github.com/users/sailsbot/gists{/gist_id}","starred_url":"https://api.github.com/users/sailsbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sailsbot/subscriptions","organizations_url":"https://api.github.com/users/sailsbot/orgs","repos_url":"https://api.github.com/users/sailsbot/repos","events_url":"https://api.github.com/users/sailsbot/events{/privacy}","received_events_url":"https://api.github.com/users/sailsbot/received_events","type":"User","site_admin":false},"created_at":"2018-12-05T08:51:59Z","updated_at":"2018-12-05T08:51:59Z","author_association":"NONE","body":"Hi @wizmea!  It looks like you may have removed some required elements from the initial comment template, without which I can't verify that this post meets our [contribution guidelines](http://bit.ly/sails-issue-guide). To re-open this issue, please copy the template from [here](https://raw.githubusercontent.com/balderdashy/sails/master/.github/ISSUE_TEMPLATE), paste it at the beginning of your initial comment, and follow the instructions in the text. Then post a new comment (e.g. \"ok, fixed!\") so that I know to go back and check.\n\nSorry to be a hassle, but following these instructions ensures that we can help you in the best way possible and keep the Sails project running smoothly.\n\n*If you feel this message is in error, or you want to debate the merits of my existence (sniffle), please contact inquiries@sailsjs.com"}}
{"actor":{"display_login":"sailsbot"}}