@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 查询指定字段的更多相关文章

  1. MongoDB查询指定字段(field)返回指定字段的方法

    使用MongoDB的时候需要只查询指定的字段进行返回,也就是类似mysql里面的 SELECT id,name,age 这样而不是SELECT *.在MongoDB里面映射(projection)声明 ...

  2. Spring Data MongoDB 查询指定字段

    DBObject dbObject = new BasicDBObject(); //dbObject.put("name", "zhangsan"); //查 ...

  3. Mybatis-Plus中使用max、sum聚合函数、只查询指定字段、查询语句多个OR处理

    聚合函数查询 可以使用以下方法 QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.select(" I ...

  4. mybatis-plus查询指定字段

    show me the code :mybais-plus版本:3.1.1 1,排除某些字段,可以同时排除多个字段排除多个字段写法: .setEntity(new User()) .select(c ...

  5. Yii2框架查询指定字段和获取添加数据的id

    指定字段: $historyinfo = Healthy::find()->select(['healthy_id','pet_name','hardware_name','hardware_c ...

  6. [Mongodb]删除指定字段

    摘要 如果想要删除mongodb中一个document的某个字段,该如何做呢? 方法模版 db.user.update({"email_state":{"$exists& ...

  7. yii 只查询指定字段

    $cri = new CDBcriteria(); $cri->addCondition( ' hid = '.$hid.' ' ); $cri->select = 'id,propert ...

  8. laravel 查询指定字段的值

    $this->model->where('id',$id)->value('user');

  9. Laravel with 查询指定的字段(非复制的哦)

    问题: 在with里面指定查询字段,结果是null. 在模型里面指定查询字段,结果是null. 解决办法: 在查询指定字段的时候要顺带着查询关联的外键,例: // user 表 id name // ...

随机推荐

  1. [NOIP模拟测试34]反思+题解

    不要陷入思维定势,如果长时间没有突破就要考虑更改大方向. 不要把简单问题复杂化. 做完的题就先放下,不管能拿多少分.不能过一段时间就回来调一下. $Solutions:$ A.次芝麻 因为$n+m$始 ...

  2. linux c(一)Helloworld

    终端的屏幕上输入命令如下: 使用vi helloworld.c打开helloworld.c文件,写下如下代码:

  3. 71、salesforce的JSON方法

    List<Merchandise__c> merchandise = [select Id,Name,Price__c,Quantity__c from Merchandise__c li ...

  4. 【计算机网络mooc】一、概述

    1.网络概述: 网络分成两个层级,用交换机连接的是子网,用路由器连接的是互连网. 互联网Internet是一个特定的互连网internet 发展3阶段,第3阶段:ISP,互联网服务提供商,缴纳费用获得 ...

  5. django 里面的更新数据(update)

    https://blog.csdn.net/qq_42606051/article/details/81162189 https://blog.csdn.net/luojie140/article/d ...

  6. RFC6241 NETCONF

    概述 NETCONF = The Network Configuration Protocol SDN = Software Define Network NETCONF协议分为传输层.消息层.操作层 ...

  7. SQL必知必会第四版自学前期表格数据的准备

    show databases;create database SAMS;use SAMS;-- 建立数据库,创建表格-- Create Customers table CREATE TABLE Cus ...

  8. Springboot+mybatis+dbcp+mysql简单集成

    1.添加依赖 <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>m ...

  9. gdb调试已在运行中的进程

    一.在服务器上调试进程,服务器上并没有源代码,所以需要将源码上传至服务器,才能调试看到源码,以下是步骤: 1.查看服务进程id:pgrep 服务名 [user@user-MP app]$ pgrep ...

  10. JS window对象 userAgent 返回用户代理头的字符串表示(就是包括浏览器版本信息等的字符串) 语法 navigator.userAgent

    userAgent 返回用户代理头的字符串表示(就是包括浏览器版本信息等的字符串) 语法 navigator.userAgent 几种浏览的user_agent.,像360的兼容模式用的是IE.极速模 ...