Spring consolidation MongoDB implementation of multiple or scope queries

Source: Internet
Author: User
Tags mongodb
Criteria c1= Criteria.where ("year"). GTE (StartYear). LTE (Endyear). and ("month"). are (Endmonth). and ("Day"). GTE ( StartDay). LTE (Endday). and
            ("Hour"). GTE (Starthour). LTE (Endhour). is (minute). and ("Startminute") . GTE (Startsecond);
Criteria C2=criteria.where ("year"). GTE (StartYear). LTE (Endyear). and ("month"). are (Endmonth). and ("Day"). GTE ( StartDay). LTE (Endday). and
            ("Hour"). GTE (Starthour). LTE (Endhour). is (minute). and ("Endminute"). LTE (Endsecond);
Criteria C3 =criteria.where ("Year"). GTE (StartYear). LTE (Endyear). and ("month"). are (Endmonth). and ("Day"). GTE ( StartDay). LTE (Endday). and
            ("Hour"). GTE (Starthour). LTE (Endhour). and (minute). GT (Startminute). LT (Endminute) ;
Criteria CR = new criteria ();

query = new query (Cr.oroperator (C1,C2,C3));
                
Getmongotemplate (). Find (query, sensorcollection.class);



Attached to the criteria method:

Criteria

Mongodb

Description

Criteria and (String key)

$and

And

Criteria Andoperator (Criteria ... criteria)

$and

And

Criteria Oroperator (Criteria ... criteria)

$or

Or

Criteria gt (Object o)

$gt

Greater than

Criteria GTE (Object o)

$gte

Greater than or equal to

Criteria in (Object ... o)

$in

Contains

The Criteria is (Object o)

$is

Equals

Criteria LT (Object o)

$lt

Less than

Criteria LTE (Object o)

$lte

Small equals

Criteria nin (Object ... o)

$nin

does not contain


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.