{"action":"created","issue":{"url":"https://api.github.com/repos/arangodb/arangojs/issues/370","repository_url":"https://api.github.com/repos/arangodb/arangojs","labels_url":"https://api.github.com/repos/arangodb/arangojs/issues/370/labels{/name}","comments_url":"https://api.github.com/repos/arangodb/arangojs/issues/370/comments","events_url":"https://api.github.com/repos/arangodb/arangojs/issues/370/events","html_url":"https://github.com/arangodb/arangojs/issues/370","id":195253842,"number":370,"title":"Problem in insert a document with a self-define key","user":{"login":"Rucchao","id":14036667,"avatar_url":"https://avatars.githubusercontent.com/u/14036667?v=3","gravatar_id":"","url":"https://api.github.com/users/Rucchao","html_url":"https://github.com/Rucchao","followers_url":"https://api.github.com/users/Rucchao/followers","following_url":"https://api.github.com/users/Rucchao/following{/other_user}","gists_url":"https://api.github.com/users/Rucchao/gists{/gist_id}","starred_url":"https://api.github.com/users/Rucchao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Rucchao/subscriptions","organizations_url":"https://api.github.com/users/Rucchao/orgs","repos_url":"https://api.github.com/users/Rucchao/repos","events_url":"https://api.github.com/users/Rucchao/events{/privacy}","received_events_url":"https://api.github.com/users/Rucchao/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-12-13T13:32:53Z","updated_at":"2016-12-13T13:40:48Z","closed_at":null,"body":"I use the code of documentCollection.save, \r\n\r\nvar db = require('arangojs')();\r\nvar collection = db.collection('my-docs');\r\nvar doc = {some: 'data'};\r\ncollection.save(doc)\r\n.then(doc1 => {\r\n    doc1._key; // the document's key\r\n    doc1._id === ('my-docs/' + doc1._key);\r\n    collection.document(doc)\r\n    .then(doc2 => {\r\n        doc2._id === doc1._id;\r\n        doc2._rev === doc1._rev;\r\n        doc2.some === 'data';\r\n    });\r\n});\r\n\r\n\r\nand get a error, as follow:\r\n\r\nError: Document handle must be a document or string\r\n    at DocumentCollection._documentHandlel\r\n    at DocumentCollection._documentPath \r\n    at DocumentCollection.document \r\n    at process._tickCallback (internal/process/next_tick.js:103:7)\r\n\r\nCould anybody help me with this ?  I am fairly new to JS and arangodb, Thanks !"},"comment":{"url":"https://api.github.com/repos/arangodb/arangojs/issues/comments/266740878","html_url":"https://github.com/arangodb/arangojs/issues/370#issuecomment-266740878","issue_url":"https://api.github.com/repos/arangodb/arangojs/issues/370","id":266740878,"user":{"login":"jsteemann","id":1423118,"avatar_url":"https://avatars.githubusercontent.com/u/1423118?v=3","gravatar_id":"","url":"https://api.github.com/users/jsteemann","html_url":"https://github.com/jsteemann","followers_url":"https://api.github.com/users/jsteemann/followers","following_url":"https://api.github.com/users/jsteemann/following{/other_user}","gists_url":"https://api.github.com/users/jsteemann/gists{/gist_id}","starred_url":"https://api.github.com/users/jsteemann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsteemann/subscriptions","organizations_url":"https://api.github.com/users/jsteemann/orgs","repos_url":"https://api.github.com/users/jsteemann/repos","events_url":"https://api.github.com/users/jsteemann/events{/privacy}","received_events_url":"https://api.github.com/users/jsteemann/received_events","type":"User","site_admin":false},"created_at":"2016-12-13T13:40:48Z","updated_at":"2016-12-13T13:40:48Z","body":"Instead of `collection.document(doc)` it should read `collection.document(doc1._key)`.\r\nThis does a primary key lookup with the inserted document's key. The code above calls `document(doc)`, and `document()` expects either a key string as its input parameter or an object with an `_id` value. But `doc` in the above code is an object which does not contain a `_key` attribute, so the call fails."}}
{"actor":{"display_login":"jsteemann"}}