The trick is subtle but it will catch you every time.
Mongo is schema-less and also type-less ... however not as clever as
CFML is ... so take 2 documents in your collection:
{
age : "24"
}
{
age : 24
}
Note how one is stored as a string and one as a number? If you search
by passing in a string, then it will only find the string documents, it
will never match on the numbers.
So for your example you need to make sure you put in a number (pssst too
many #..# ):
<cfset results = MongoCollectionFind("mongo", "myNewCollection", {"age":
Int(form.selectedAge)} ) />
This will get you what you need.
On 12/02/2013 04:37, Ejaz Khan wrote:
Hi All,
I am new to Mongo in BD hence my question might seem trivial so bear
with me.
Question...
I want to pass variables (URL, FORM, etc) in
the MongoCollectionFind statement. Example could be <cfset results =
MongoCollectionFind("mongo", "myNewCollection", {"age":
#form.selectedAge#}) /> but it doesn't work. I don't get any results
back. If I hard-code the age ( <cfset results =
MongoCollectionFind("mongo", "myNewCollection", {"age": 24}) /> ), I
get the correct results back. What trick am I missing here?
Regards,
Ejaz
--
--
online documentation: http://openbd.org/manual/
http://groups.google.com/group/openbd?hl=en
---
You received this message because you are subscribed to the Google
Groups "Open BlueDragon" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.
--
--
online documentation: http://openbd.org/manual/
http://groups.google.com/group/openbd?hl=en
---
You received this message because you are subscribed to the Google Groups "Open BlueDragon" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.