1
I have a collection called users on Mongo with approximately 1000 values. Access Mongo through Mongodb . NET Driver, at the moment everything works normally. But these past few days I’ve been wanting to retrieve some documents from this collection manually, and I didn’t want to have to tamper with my code for this.
I executed:
db.usuarios.find({})
Who returned me a large amount of documents(Proving that it is working..)
But when executing:
db.usuarios.find({"_id":"295092462215757825"})
nothing returns me. until I tried:
db.usuarios.find({"_id":295092462215757825})
and nothing. as shown in the image below..
Source code for my Github project https://github.com/ZaynBot/ZaynBot
The ID is auto-generated by my code, so it is not an Objectid but a ulong.
What could possibly result in no value? I’m sure there is even why I got the value through Mongodb . NET Driver.
Was this find by id working before or hadn’t you tried it yet? Another thing: you can post in (code format) a sample of the return of your findAll, which contains a document?
– Pedro Ramos
@Pedroramos find works on the ids that appear in findAll, or at least on the initials.. This one form?
– AiltonSilvaSC
@Pedroramos used the Robo 3T and I could see all the documents, I can look one by one, but when I use the find does not appear, even being in Robo 3T.. Until I copied the code that appears in Robo 3T and not found in Mongo...
– AiltonSilvaSC
@Pedroramos Thanks, I think I found the problem, in case I was not converting the number to ulong, only putting the same raw number, after sending a sample of findAll I noticed and decided to test. I went to try with
db.usuarios.find({"_id":NumberLong("383711472221421589")})
he is now finding all the documents I ask for. D– AiltonSilvaSC
All right, then. I’m glad you made it!
– Pedro Ramos