mongodb 查询指定字段
@Autowired
MongoDatabase database; @Override
public List<Grid> getAdditionalGrid(String collection, int cityDataId) {
MongoCollection<Document> gridColl = database.getCollection("grid");
FindIterable<Document> grids = gridColl.find(Filters.eq("cityDataId", cityDataId))
.projection(new BasicDBObject().append("grid_id", true).append("_id",true));
} }
mongodb 查询指定字段的更多相关文章
- MongoDB查询指定字段(field)返回指定字段的方法
使用MongoDB的时候需要只查询指定的字段进行返回,也就是类似mysql里面的 SELECT id,name,age 这样而不是SELECT *.在MongoDB里面映射(projection)声明 ...
- Spring Data MongoDB 查询指定字段
DBObject dbObject = new BasicDBObject(); //dbObject.put("name", "zhangsan"); //查 ...
- Mybatis-Plus中使用max、sum聚合函数、只查询指定字段、查询语句多个OR处理
聚合函数查询 可以使用以下方法 QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.select(" I ...
- mybatis-plus查询指定字段
show me the code :mybais-plus版本:3.1.1 1,排除某些字段,可以同时排除多个字段排除多个字段写法: .setEntity(new User()) .select(c ...
- Yii2框架查询指定字段和获取添加数据的id
指定字段: $historyinfo = Healthy::find()->select(['healthy_id','pet_name','hardware_name','hardware_c ...
- [Mongodb]删除指定字段
摘要 如果想要删除mongodb中一个document的某个字段,该如何做呢? 方法模版 db.user.update({"email_state":{"$exists& ...
- yii 只查询指定字段
$cri = new CDBcriteria(); $cri->addCondition( ' hid = '.$hid.' ' ); $cri->select = 'id,propert ...
- laravel 查询指定字段的值
$this->model->where('id',$id)->value('user');
- Laravel with 查询指定的字段(非复制的哦)
问题: 在with里面指定查询字段,结果是null. 在模型里面指定查询字段,结果是null. 解决办法: 在查询指定字段的时候要顺带着查询关联的外键,例: // user 表 id name // ...
随机推荐
- Python(二)
函数Python的函数支持递归.默认参数值.可变参数,但不支持函数重载.为了增强代码的可读性,可以在函数后书写“文档字符串”(Documentation Strings,或者简称docstrings) ...
- BZOJ 1005: [HNOI2008]明明的烦恼(高精度+prufer序)
传送门 解题思路 看到度数和生成树个树,可以想到\(prufer\)序,而一张规定度数的图的生成树个数为\(\frac{(n-2)!}{\prod\limits_{i=1}^n(d(i)-1)!}\) ...
- Ubuntu下实现Nginx+Tomcat实现负载均衡
先说一下为什么写这个文章,在性能测试过程中,我们可能会关注很多指标,比如CPU.IO.网络.磁盘等,通过这些指标大致可以判断哪个环节遇到了性能瓶颈,但是当这些指标无法判断出性能瓶颈时,我们可能就需要对 ...
- PAT_A1037#Magic Coupon
Source: PAT A1037 Magic Coupon (25 分) Description: The magic shop in Mars is offering some magic cou ...
- upc组队赛5 Bulbs
Bulbs 题目描述 Greg has an m × n grid of Sweet Lightbulbs of Pure Coolness he would like to turn on. Ini ...
- charles使用教程
概述 Charles是目前最强大的http调试工具,在界面和功能上远胜于Fiddler,同时是全平台支持.是收费软件,可以试用15分钟,下面提供了破解方法. 安装破解 https://www.cn ...
- 【react】---react项目中如何使用iconfont
一.路由配置 export const TabBarRouter = [ { path:"/home", icon:"\ue628", name:"首 ...
- python 模拟双色球输出
编写Python函数:完成一个双色球彩票的模拟生成过程, 其中前六个为红色球,数字范围1-33,不可重复.最后一个为蓝色球 1-16. import random #red_nums是采集红色球的数字 ...
- Machine code transfer into assembly code
#include <stdio.h> const char shell[]="\x0f\x01\xf8\xe8\5\0\0\0\x0f\x01\xf8\x48\xcf" ...
- spring_AOP的注解开发
logger日志类: package cn.mepu.utils; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.la ...