Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mongoose ObjectId not be recognised as _id in create #232

Closed
hcbh96 opened this issue Mar 3, 2018 · 7 comments
Closed

Mongoose ObjectId not be recognised as _id in create #232

hcbh96 opened this issue Mar 3, 2018 · 7 comments

Comments

@hcbh96
Copy link

hcbh96 commented Mar 3, 2018

@daffl I've been slightly spamming slack and I really apologise for that.

I've commented on another issue but thought I should open another one in case people have the same problem in the future

I am currently able to create one MongoDB user, along with an _id of type ObjectId,

I am able to authenticate my user and use that authentication to fetch the list of users, this is a user object.

{` "total": 1, "limit": 10, "skip": 0, "data": [ { "_id": "5a9a8c3e4b0aac22847635fe", "updatedAt": "2018-03-03T11:51:26.171Z", "createdAt": "2018-03-03T11:51:26.171Z", "email": "[email protected]", "__v": 0 } ] `}

What i am not able to do is create a new user as each time I try I get an error code of 409 with the following response

{ "name": "Conflict", "message": "id: null already exists.", "code": 409, "className": "conflict", "errors": { "id": null } }

I am really sorry for sending so many messages on this, I just really want and need to get my head around what is going on. Thank you very much for providing any insight

@daffl
Copy link
Member

daffl commented Mar 3, 2018

Please share a repository that reproduces your issue. I don't see id in the code samples but it looks like it has been added as a unique constraint.

@hcbh96
Copy link
Author

hcbh96 commented Mar 3, 2018

@hcbh96
Copy link
Author

hcbh96 commented Mar 3, 2018

Thank you so much, I've transferred it from bitbucket to GitHub, hopefully, sooner or later I can give back to the community

@daffl
Copy link
Member

daffl commented Mar 4, 2018

Do you have any other changes you made? The repository just looks like a unmodified generated application.

@hcbh96
Copy link
Author

hcbh96 commented Mar 4, 2018

@daffl Sorry I forgot to push the verify phone branch up, it is now there.

@hcbh96
Copy link
Author

hcbh96 commented Mar 5, 2018

I've managed to work around it, the error was being caused by an index that I must have previously created and attached to the collection. I solved the issue by dropping the collection completely and then restarting it. The error I was getting was the same as the one mentioned in this post Automattic/mongoose#2471 . Thank you very much though @daffle and sorry to have been a pain.

@daffl
Copy link
Member

daffl commented Mar 5, 2018

👍 Glad you figured it out.

@daffl daffl closed this as completed Mar 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants