jan
jan
BABetter Auth
Created by jan on 3/25/2025 in #help
MongoDB Error Duplicate key
I sometimes get this error when authenticating with MongoDB:
errorResponse: {
apps/backend dev: index: 0,
apps/backend dev: code: 11000,
apps/backend dev: errmsg: 'E11000 duplicate key error collection: pushwave.sessions index: id_1 dup key: { id: null }',
apps/backend dev: keyPattern: { id: 1 },
apps/backend dev: keyValue: { id: null }
apps/backend dev: },
errorResponse: {
apps/backend dev: index: 0,
apps/backend dev: code: 11000,
apps/backend dev: errmsg: 'E11000 duplicate key error collection: pushwave.sessions index: id_1 dup key: { id: null }',
apps/backend dev: keyPattern: { id: 1 },
apps/backend dev: keyValue: { id: null }
apps/backend dev: },
It is because my id is saved under column _id not id therefore all sessions have id null - duplicate. How can I change which column is checked for ID? Because until now the only possible fix was to delete all sessions from table.
8 replies