• java 调用mongo 判断大于等于 并且小约等于<=


    初始化mongo链接

    MongoClientOptions options = new Builder().connectionsPerHost(300).connectTimeout(20000)
    .maxConnectionIdleTime(60000).maxWaitTime(1000 * 60 * 2).socketKeepAlive(true).socketTimeout(60000)
    .threadsAllowedToBlockForConnectionMultiplier(50).build();
    MongoCredential credential = MongoCredential.createCredential("foest", "markett",
    "123456".toCharArray());
    ServerAddress serverAddress = new ServerAddress("192.1.15.19", 20000);
    MongoClient mongoClient = new MongoClient(serverAddress, credential, options);
    database = mongoClient.getDatabase("market-data-forex-test");
    kLineCollection = database.getCollection("KLine");

    封装查询条件:

    BasicDBObject query = new BasicDBObject();
     query.append("code", "CU00");
    query.append("period", 1);
    query.put("barTime", new BasicDBObject("$gte", 20171127210100L).append("$lt", 20171127210200L));
    //查询该条件下数据的数量
    long klineAmount = kLineCollection.countDocuments(query);
     
  • 相关阅读:
    表单提交:button input submit 的区别
    JavaScript中改变this指针的注意事项
    宝塔服务器配置nginx刷新404的问题汇总
    ES6笔记整理
    axios网络请求
    v-model双向绑定
    v-bind动态绑定
    前端模块化
    vue router 路由
    JS高阶函数
  • 原文地址:https://www.cnblogs.com/redBack/p/10020327.html
Copyright © 2020-2023  润新知