I have a python script that receive (from a node.js script) an _id for a mongodb document as an argument.Using that value I'm trying to query the db and retrieve a document.
However, when i try to run the script it throws an error saying "'xxxxxxxxxx'is not a valid ObjectId, it must be a 12-byte input or a 24-character hex string".
my script where the error is causing: result = db.req.find_one({"_id": ObjectId(sys.argv[1])})
When i check the type() of the sys.argv[1] it says string. I thought wrapping the string around ObjectId should do the trick.
Anyone one know whats the reason causing the issue?
Thanks in advance..
via Catzeye
No comments:
Post a Comment