emberfeather / mongo4cf

Simple CFML wrapper for the Mongo Java driver

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Search Document for ObjectID

PrinzFritz opened this issue · comments

Menue = menues.findOne({_id:ObjectID("4f032369e4b0f8b2f78219d7")}) shows an Error:

" No matching Method/Function for OBJECTID(string) "

Menue = menues.findOne({,_id:"4f032369e4b0f8b2f78219d7"}) is empty although the _id exists

how to search for automated _id (ObjectID) ?

Since MongoDB is case-sensitive you have to put the struct keys in quotes so that the CFML engine does not put the key in all uppercase. In this case Mongo is seeing a search for a _ID key. Try this instead:

Menue = menues.findOne({"_id":"4f032369e4b0f8b2f78219d7"})

no ,sorry the Result is: 0

i have show the code here: http://www.cfblog.de/mongo1.jpg

I will check into this more. I usually set my own _id value manually before I save the record so I hadn't noticed that it won't do a string match on an automatically generated _id.

I'll check into it and see if I can come up with a good solution for it.

I added in an attempt to automatically detect when an _id value is 24 character long (this should be the length of the generated ids) and have it automatically create the ObjectID object.

You can see the changes in the 471424b commit.

If you can verify that those changes fix the problem for you that would be awesome.

it works, great , THX !!