Giter Club home page Giter Club logo

mongo-lambda-query's Introduction

mongo-lambda-query

a lambda-based object-oriented mongo query plug-in
基于lambda表达式,且面向对象的mongo数据库查询插件。
先赞后看,🌟🌟🌟

使用步骤:

  1. 引入maven依赖文件
        <dependency>
            <groupId>io.github.darmi7</groupId>
            <artifactId>mongo-lambda-query</artifactId>
            <version>1.1.0</version>
        </dependency>
    
  2. 开启插件注解,加上需要扫描mongo实体的包路径
    @EnableMongoLambdaQuery
    @EnableMongoRepositories(basePackages = "com.darmi.demo.repository.mongo")
    public class Application
    
  3. 编写查询代码
        @Repository
        public interface TaskRepository extends MongoRepository<Task, String> {
    
            default Task one(TaskCriteria taskCriteria) {
                return MongoLambdaQuery.lambdaQuery(Task.class)
                    .is(Task::getName, taskCriteria.getName())
                    .one();
            }
            
            default List<Task> list(TaskCriteria taskCriteria) {
                return MongoLambdaQuery.lambdaQuery(Task.class)
                    .gt(Task::getCreated, taskCriteria.getBegin())
                    .lt(Task::getCreated, taskCriteria.getEnd())
                    .list();
            }
            
            
            default Page<Task> search(TaskCriteria taskCriteria) {
                return MongoLambdaQuery.lambdaQuery(Task.class)
                        .is(Task::getName, taskCriteria.getName())
                        .is(Task::getType, taskCriteria.getFuzzyName())
                        .reg(Task::getName, taskCriteria.getName())
                        .gt(Task::getPoints, taskCriteria.getPoints())
                        .gt(Task::getCreated, taskCriteria.getBegin())
                        .lt(Task::getCreated, taskCriteria.getEnd())
                        .page(taskCriteria.getPagination());
            }
        }
    
  4. 具体使用案例参考demo模块,如有什么问题欢迎留言。
    原理分析可以查看博客:https://blog.csdn.net/qq_28175019/article/details/129100748

mongo-lambda-query's People

Contributors

darmi7 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.