Home  >  Q&A  >  body text

java - 如何根据id查找该对象字段的值 而不是查找对象全部信息?

mysql可以指定select 后面的字段

mongo 通过java 怎么实现该功能 比如我要根据c_oid得到c_title java代码怎么写?

PHP中文网PHP中文网2741 days ago373

reply all(2)I'll reply

  • ringa_lee

    ringa_lee2017-04-18 10:27:29

    It’s just a normal query, please refer to the official documentation.

    reply
    0
  • PHPz

    PHPz2017-04-18 10:27:29

    It’s very detailed here
    http://mongodb.github.io/mong...

    For example, fields include below contains the fields you want to return

    collection.find(eq("c_oid", "****"))
                    .projection(fields(include("c_title"), excludeId()));
    

    reply
    0
  • Cancelreply