HashtagSell / posting-api

API for storage and retrieval of posting details for Hashtagsell
0 stars 0 forks source link

Duplicate key error #5

Closed that1guy closed 9 years ago

that1guy commented 9 years ago
  1. POST first object into posting API.
  2. Success.
  3. Post SECOND object into posting API.
  4. See error below.
{
  "name": "PersistenceError",
  "message": "unable to store posting",
  "sourceError": {
    "jse_shortmsg": "save of posting b63b4d2c84004aa593173367d5b54157 failed",
    "jse_summary": "save of posting b63b4d2c84004aa593173367d5b54157 failed: insertDocument :: caused by :: 11000 E11000 duplicate key error index: hashtagsell-posting-v1.postings.$external.threeTaps.id_1  dup key: { : null }",
    "jse_cause": {
      "name": "MongoError",
      "code": 11000,
      "err": "insertDocument :: caused by :: 11000 E11000 duplicate key error index: hashtagsell-posting-v1.postings.$external.threeTaps.id_1  dup key: { : null }"
    },
    "message": "save of posting b63b4d2c84004aa593173367d5b54157 failed: insertDocument :: caused by :: 11000 E11000 duplicate key error index: hashtagsell-posting-v1.postings.$external.threeTaps.id_1  dup key: { : null }"
  },
  "statusCode": 500
}
brozeph commented 9 years ago

Ok, I have a fix in for this... I created a migration file to update the index on external.threeTaps.id to no longer require unique values. Null, in and of itself, is a value... this occurring more than once (as it would for our own postings) was causing the problem.

git pull
gulp mongo-start
mongo localhost:27017/hashtagsell-posting-v1 ./init/data-migrations/v0.1.1.js
NODE_ENV=local npm start
that1guy commented 9 years ago

Awesome!

On Thursday, February 12, 2015, Joshua Thomas notifications@github.com wrote:

Ok, I have a fix in for this... I created a migration file to update the index on external.threeTaps.id to no longer require unique values. Null, in and of itself, is a value... this occurring more than once (as it would for our own postings) was causing the problem.

git pull gulp mongo-start mongo localhost:27017/hashtagsell-posting-v1 ./init/data-migrations/v0.1.1.js NODE_ENV=local npm start

— Reply to this email directly or view it on GitHub https://github.com/HashtagSell/posting-api/issues/5#issuecomment-74077009 .