Need help in constructing query to compare values of two fields

152 views
Skip to first unread message

engineer software

unread,
Aug 2, 2011, 10:50:17 AM8/2/11
to mongodb-user
Following is the json object
{ "width":895,
"height":1000,
"imageType":"Generic"
}


I need to construct a query where I am supposed to get all records
where
"width": $lt "height"

Any ideas???

Andreas Jung

unread,
Aug 2, 2011, 11:29:32 AM8/2/11
to mongod...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Is is not supported except using slow $where queries. Instead store the
aspect ratio and query for that.

- -aj
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQGUBAEBAgAGBQJOOBfaAAoJEADcfz7u4AZj8/QLvihoVUx3/aMYV3UreqNTuEQr
vrjxaeuXUhk0WgrAmuc042EdCy1flLjf/fbHWjrJWWxr55SMGUB2L3JU2fziI6Ra
e3zsw9BCxp+NjlNC0aMktUYZQp6qU+HEzUamPsaQgswdpAXM/cc6WNHa5u8YgSHj
xv5G0WZWHuxIQtM2PCf2IBjvldegnc7W3nys+Cw3wS5yF3/Zs0NeiCJm2Xwk5QxW
jh3cWTaTLxfWXleWwC79PasfoBbGdOjBZxeyf+MYxOa8GPwZQWsGRcBWb33J70VP
NAcRtRp6HdYXIxmgksEr1JkX0nop/xrGZ2j4bVa6oozHrwmXcAEXRIUfiGSDCf8E
PMs6ae3yq2qbob4DDcX/XlTX8dKoDxAgdCyErClxF4xr4+C3VsqF97iCfFk0Y6Ch
BmgPZlFZWNN1yQdRZL1e/u8i1F6GKE+iJHO+IHTF8Lgiz8ND8ZKvlJ2mA554mnXj
WwuTG2Y9I1ToQmZAkyYAxwlLKwChcz8=
=C+1b
-----END PGP SIGNATURE-----

lists.vcf

engineer software

unread,
Aug 2, 2011, 11:56:45 AM8/2/11
to mongodb-user
Thanks Andreas,

It works : $where: function() { return this.width < this.height}";



On Aug 2, 4:29 pm, Andreas Jung <li...@zopyx.com> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> engineer software wrote:
> > Following is the json object {    "width":895, "height":1000,
> > "imageType":"Generic" }
>
> > I need to construct a query where I am supposed to get all records
> > where "width": $lt "height"
>
> Is is not supported except using slow $where queries. Instead store the
> aspect ratio and query for that.
>
> - -aj
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.11 (Darwin)
> Comment: Using GnuPG with Mozilla -http://enigmail.mozdev.org/
>
> iQGUBAEBAgAGBQJOOBfaAAoJEADcfz7u4AZj8/QLvihoVUx3/aMYV3UreqNTuEQr
> vrjxaeuXUhk0WgrAmuc042EdCy1flLjf/fbHWjrJWWxr55SMGUB2L3JU2fziI6Ra
> e3zsw9BCxp+NjlNC0aMktUYZQp6qU+HEzUamPsaQgswdpAXM/cc6WNHa5u8YgSHj
> xv5G0WZWHuxIQtM2PCf2IBjvldegnc7W3nys+Cw3wS5yF3/Zs0NeiCJm2Xwk5QxW
> jh3cWTaTLxfWXleWwC79PasfoBbGdOjBZxeyf+MYxOa8GPwZQWsGRcBWb33J70VP
> NAcRtRp6HdYXIxmgksEr1JkX0nop/xrGZ2j4bVa6oozHrwmXcAEXRIUfiGSDCf8E
> PMs6ae3yq2qbob4DDcX/XlTX8dKoDxAgdCyErClxF4xr4+C3VsqF97iCfFk0Y6Ch
> BmgPZlFZWNN1yQdRZL1e/u8i1F6GKE+iJHO+IHTF8Lgiz8ND8ZKvlJ2mA554mnXj
> WwuTG2Y9I1ToQmZAkyYAxwlLKwChcz8=
> =C+1b
> -----END PGP SIGNATURE-----
>
>  lists.vcf
> < 1KViewDownload

Andreas Jung

unread,
Aug 2, 2011, 12:08:04 PM8/2/11
to mongod...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

...which is not recommendable (as said). No indexes can be used.

- -aj

engineer software wrote:
> Thanks Andreas,
>
> It works : $where: function() { return this.width < this.height}";
>
>
>

> On Aug 2, 4:29 pm, Andreas Jung <li...@zopyx.com> wrote: engineer


> software wrote:
>>>> Following is the json object { "width":895, "height":1000,
>>>> "imageType":"Generic" } I need to construct a query where I am
>>>> supposed to get all records where "width": $lt "height"
> Is is not supported except using slow $where queries. Instead store
> the aspect ratio and query for that.
>

> -aj
>>
>> lists.vcf < 1KViewDownload
>

- --
ZOPYX Limited | zopyx group
Charlottenstr. 37/1 | The full-service network for Zope & Plone
D-72070 T�bingen | Produce & Publish
www.zopyx.com | www.produce-and-publish.com
- ------------------------------------------------------------------------
E-Publishing, Python, Zope & Plone development, Consulting


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQGUBAEBAgAGBQJOOCDkAAoJEADcfz7u4AZjK0cLv0RhmaXhtAshKw2OJ8UE6bTf
we9vo4YksW25jXgEC4uFRWpO3LUhLuGqM9FLDmU7uBKg8rarB/JMACKtgNkp4P/R
eJbcRP+HBtJ8oVbi/ysMzAu3IYgaZ33Cj7btJjJq5vFMz4NqC0/ArS9CPPyG4rll
lPiCBPcSMokbTNuLJiv9d2DdjIO6DZLH9d6xNuUDXgDEmW3BTJlfXkhYpp1qINWW
3ojGa3VhBqWr4IUsUdJUCcy5UyjXYQV7zVncJ8mm5XUcjHJ/tdEFmfOfsTM6Aq2S
PjjtmIqKe9eBoJvMJ44MrYZ/fruZkhHoFv94KhjpUJ0Oak5ihBH1A8YMTB7JroQI
EdgOr6YDSZUOELniLpgTbFoHe/WVW1hwz3K0hwAJLgiQWzTBkzxPuFUOp5oi24Fd
NbaFUDHF4E9n+UUUKYLFQgCfWdm/MmG/3Qaab7geYS7Ehl3REdT0VBQtSR1FQaPV
USRwgQW516VvLOxxEAjt2RrpoWrDIXs=
=F0Jn
-----END PGP SIGNATURE-----

lists.vcf
Reply all
Reply to author
Forward
0 new messages