{"action":"opened","issue":{"url":"https://api.github.com/repos/rgreschner/mongodb-iot-mqtt-example/issues/26","labels_url":"https://api.github.com/repos/rgreschner/mongodb-iot-mqtt-example/issues/26/labels{/name}","comments_url":"https://api.github.com/repos/rgreschner/mongodb-iot-mqtt-example/issues/26/comments","events_url":"https://api.github.com/repos/rgreschner/mongodb-iot-mqtt-example/issues/26/events","html_url":"https://github.com/rgreschner/mongodb-iot-mqtt-example/issues/26","id":55736597,"number":26,"title":"Redesign DB schema (allows for duplicate keys by means of different field order as is)","user":{"login":"rgreschner","id":210646,"avatar_url":"https://avatars.githubusercontent.com/u/210646?v=3","gravatar_id":"","url":"https://api.github.com/users/rgreschner","html_url":"https://github.com/rgreschner","followers_url":"https://api.github.com/users/rgreschner/followers","following_url":"https://api.github.com/users/rgreschner/following{/other_user}","gists_url":"https://api.github.com/users/rgreschner/gists{/gist_id}","starred_url":"https://api.github.com/users/rgreschner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rgreschner/subscriptions","organizations_url":"https://api.github.com/users/rgreschner/orgs","repos_url":"https://api.github.com/users/rgreschner/repos","events_url":"https://api.github.com/users/rgreschner/events{/privacy}","received_events_url":"https://api.github.com/users/rgreschner/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rgreschner/mongodb-iot-mqtt-example/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-01-28T10:08:57Z","updated_at":"2015-01-28T10:08:57Z","closed_at":null,"body":"As pointed out by @alanderex , it is currently possible to mix-up ids of sensor data because of field order stored in compound index.\r\nE.g. when inserting two documents\r\n\r\n```\r\ndb.idTest.insert({\"_id\":{x:1, y:0}})\r\n```\r\n\r\nand\r\n\r\n```\r\ndb.idTest.insert({\"_id\":{y:0, x:1}})\r\n```\r\n\r\nactually 2 documents get created instead of one. This also affects queries.\r\n\r\nProblem can be mitigated by creating unique constraint on id fields, but since this seems to be a general problem with some drivers (e.g. Python), a flattening of compund index fields into collection fields and the introduction of unique constraints on them seems more reasonable.\r\n\r\n"}}