使用spring-data-mongo查詢數據


  • cid:1:privileges:groups:find


    本帖下載内容已隐藏,请登入以查看隐藏内容!

    返回

    {
      "id": "58b98b62edbc641da00c10c6",
      "age": 18,
      "firstName": "ken",
      "lastName": "chen",
      "email": "123@163.com",
      "mobilePhone": "13001231234",
      "homePhone": null,
      "birthday": 1488554849965,
      "createDateTime": 1488554849965
    }

    由於在module定了User模型有homePhone屬性

    我們在User.java加入@JsonInclude(Include.NON_NULL),也可加在屬性上


    再次調用得到

    {
      "id": "58b98b62edbc641da00c10c6",
      "age": 18,
      "firstName": "ken",
      "lastName": "chen",
      "email": "123@163.com",
      "mobilePhone": "13001231234",
      "birthday": 1488554849965,
      "createDateTime": 1488554849965
    }

     

    調整UserRepository.java


    {
      "id": "58b98b62edbc641da00c10c6",
      "firstName": "ken",
      "lastName": "chen"
    }

     



  • 專業分析,值得收藏


登录后回复
 

与 萌阔论坛 的连接断开,我们正在尝试重连,请耐心等待