Instead of $where in MongoDB

Source: Internet
Author: User

Before referring to MongoDB in the $where query time, MONGO in the where query is not indexed, so the efficiency of the query is very low, so can not $where as much as possible without $where, and in aggregate () there is no where query, so $ Where today to optimize the $where query, generally our where query is generally queried in the database two different fields are greater than or not equal to the case, for example: Db.datas.find ({$where: "this[" 54BCFC6C329AF61034F7C2FC '].testret!== this[' 54bcfc6c329af61034f7c2fc '].taskret '}), now we can write it this way:

Db.datas.find ({' this[' 559e65b3040a5ee37e4505b3 '].testret ': {$ne: ' this[' 559e65b3040a5ee37e4505b3 '].taskret '}})

You can use the This keyword, without $where query.

Instead of $where in MongoDB

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.