//查
public StatisticsSchoolPracticeView findByUser(String userId,int statOrgType,int inDateType){
Query query = new Query(Criteria.where("userId").is(userId).and("statOrgType")
.is(statOrgType).and("inDateType").is(inDateType));
return template.findOne(query,StatisticsSchoolPracticeView.class);
} //改,不存在则新增
public int upsert(StatisticsSchoolPracticeView view){
Query query = new Query(Criteria.where("userId").is(view.getUserId()).and("statOrgType")
.is(view.getStatOrgType()).and("inDateType").is(view.getInDateType()));
String json = JSON.toJSONString(view);
Document document = Document.parse(json);
Update update = Update.fromDocument(document);
return (int)template.upsert(query,update,StatisticsSchoolPracticeView.class).getMatchedCount();
}
 String toDay = DateUtils.format(new Date());
List<String> moguNoSet = moguActiveUserDao.findDistinctMoguNos(toDay); public List<String> findDistinctMoguNos(String toDay) {
Query query = new Query();
query.addCriteria(Criteria.where("date").lte(toDay));
return template.findDistinct(query,"moguNo",MoguActiveUserDto.class,String.class);
}

mongodb查询修改的更多相关文章

  1. MongoDB查询修改操作语句命令大全

    MongoDB查询更新操作语句命令大全 查询操作 1.条件操作符 <, <=, >, >= 这个操作符就不用多解释了,最常用也是最简单的db.collection.find({ ...

  2. Mongodb:修改文档结构后出现错误:Element '***' does not match any field or property of class ***.

    Mongodb:修改文档结构后出现错误:Element '***' does not match any field or property of class ***. Mongodb是一种面向文档的 ...

  3. MongoDb进阶实践之三 MongoDB查询命令详述

    一.引言           上一篇文章我们已经介绍了MongoDB数据库的最基本操作,包括数据库的创建.使用和删除数据库,文档的操作也涉及到了文档的创建.删除.更新和查询,当然也包括集合的创建.重命 ...

  4. MongoDB update修改器: 针对Fields的$修改器 $inc $set $unset

    MongoDB update修改器: $inc $set $unset $push $pull $pop 针对Fields的$修改器 $set: { $set: { key: value } } $s ...

  5. MongoDB数组修改器更新数据(转)

    MongoDB数组修改器更新数据    这里,我们将了解一下数组修改器.数组,是我们经常看到和使用到的且非常有用的数据结构:它不仅可以通过索进行引用,还可以作为集合来使用.数组修改器,顾名思义,它是用 ...

  6. MongoDb进阶实践之四 MongoDB查询命令详述

    一.引言 上一篇文章我们已经介绍了MongoDB数据库的最基本操作,包括数据库的创建.使用和删除数据库,文档的操作也涉及到了文档的创建.删除.更新和查询,当然也包括集合的创建.重命名和删除.有了这些基 ...

  7. mongodb查询速度慢是什么原因?

    mongodb查询速度慢是什么原因? 通过mongodb客户端samus代码研究解决问题         最近有项目需要用到mongodb,于是在网上下载了mongodb的源码,根据示例写了测试代码, ...

  8. MongoDB查询转对象是出错Element '_id' does not match any field or property of class

    MongoDB查询转对象是出错Element '_id' does not match any field or property of class   解决方法: 1.在实体类加:[BsonIgno ...

  9. MongoDB查询操作限制返回字段的方法

    这篇文章主要介绍了MongoDB查询操作限制返回字段的方法,需要的朋友可以参考下   映射(projection )声明用来限制所有查询匹配文档的返回字段.projection以文档的形式列举结果集中 ...

随机推荐

  1. 微信PC版Hook研究思维导图

  2. JS中constructor,prototype

    First: this this定义: this就是函数赖以执行的对象. 分析这句话: 1. this是对象. 2. this依赖函数执行的上下文环境. 3. this存在函数中. 直接看例子: al ...

  3. SQLCommand命令、DbTransaction事务

    一.SqlDataReader SqlConnection conn = new SqlConnection("server=10.126.64.11;user=it_oper;pwd=IT ...

  4. Oracle自动化安装脚本-part01-亲试ok

      #!/bin/bash   node_num=$1 base_config=./network.conf   网络配置文件 software_config=./software.conf  软件包 ...

  5. 012_Linux驱动之_wait_event_interruptible

    1. 首先这篇博客讲解得挺好的,推荐 wait_event_interruptible 使用方法 2 .函数原型: #define wait_event_interruptible(wq, condi ...

  6. Oracle 审计 部署监控 user DML操作

    1.移动audit表及索引到dbadmin表空间 alter table aud$ move tablespace DBADMIN;alter table AUDIT$ move tablespace ...

  7. [Luogu] 魔板

    https://www.luogu.org/problemnew/show/P1275 #include <iostream> #include <cstdio> #inclu ...

  8. 十七、程序包管理之yum和编译安装

    YUM Redhat二次发行版 Yellow Dog Linux,上使用的yum(Yellowdog Update Modifier),由yellow dog 研发 yum命令的工作原理 1.接收用户 ...

  9. NTP 协议介绍

    NTP协议 NTP(Network Time Protocol,网络时间协议)是由RFC 1305定义的时间同步协议,用来在分布式时间服务器和客户端之间进行时间同步.NTP基于UDP报文进行传输,使用 ...

  10. Hdu5762

    Hdu5762 题意: 你n个点,让你找两个数对,A,B和C,D,使得A和B的曼哈顿距离等于C和D的曼哈顿距离,问是否存在这样的对,A!=C且B!=D. 解法: 直接暴力判断,时间复杂度是 $ O(n ...