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

Can't use generic string _ids #1

Closed
stephencelis opened this issue May 9, 2012 · 2 comments · Fixed by #134
Closed

Can't use generic string _ids #1

stephencelis opened this issue May 9, 2012 · 2 comments · Fixed by #134

Comments

@stephencelis
Copy link

Monk always casts any _id parameter that's a string into a BSON ObjectID. This prevents the insertion of new records that use a string _id that doesn't conform to ObjectID spec and it prevents the retrieval of existing records.

Is this restriction by design? Sometimes it's nice to be able to assign your own unique string identifiers (e.g., for upserting stats data).

Not sure if or how you'd want to support this. Maybe a global option to not auto-cast these ids? Happy to work on a pull request if you're OK supporting the feature.

@rauchg
Copy link
Contributor

rauchg commented May 22, 2012

Oh shoot, didn't see this haha. Definitely, we should have an options castIds: false

rauchg pushed a commit that referenced this issue Mar 1, 2014
Bugfix for parameter handling in findAndModify
@robertfmurdock
Copy link

It looks like this issue (or one very similar) just started happening again sometime between 0.81 and 0.9. I was able to insert using custom ids before and now I get exceptions when using non-ObjectID compliant strings.

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

Successfully merging a pull request may close this issue.

3 participants