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

Query by ObjectID hexadecimal string #45

Closed
adrian-catana opened this issue Feb 12, 2016 · 2 comments
Closed

Query by ObjectID hexadecimal string #45

adrian-catana opened this issue Feb 12, 2016 · 2 comments
Assignees

Comments

@adrian-catana
Copy link

How can I query for document based on ObjectID as string? The only way I could get it to work is
to use Mongo.Ecto.ObjectID.dump from Mongo.Ecto project, like this:

Mongo.find(MongoPool, "some_collection", %{_id: elem(Mongo.Ecto.ObjectID.dump("55e724bf44f4173c876919f9"),1) })

is there a way to do it and not depend on an external project?

@michalmuskala
Copy link
Collaborator

I think a helper function for this directly in Mongo could be useful.

@ericmj
Copy link
Collaborator

ericmj commented Feb 12, 2016

We can add encode and decode functions to ObjectId.

@michalmuskala michalmuskala self-assigned this Feb 13, 2016
michalmuskala added a commit to michalmuskala/mongodb that referenced this issue Feb 13, 2016
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

3 participants