亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

根據List里面的值,查詢模糊查詢mongodb,最好用springdata mongodb

根據List里面的值,查詢模糊查詢mongodb,最好用springdata mongodb

HUWWW 2019-01-16 22:36:46
現在條件是一個List,如 type["sh","th"] //不是數據庫type里面的全值,只有一個前綴 根據這個查詢下面數據庫,type里面有sh和th為前綴的,整個document 結果應該是1,2,4條record(document)都應該被查出來 怎么實現,最好用springdata mongdb,其它java方式也行 比如數據庫有3條record如下: { "_id": "5bcfe3367f0xxxxx02", "type": [ "sh-adidas", "th-NB" ], "status": "active", "lastUpdateDate": "2018-10-25T17:27:41+08:00" } { "_id": "5bcfe3367f0xxxxx02", "type": [ "bj-nike", "sh-adidas" ], "status": "active", "lastUpdateDate": "2018-10-25T17:27:41+08:00" } { "_id": "5bcfe3367f0xxxxx02", "type": [ "bj-nike" ], "status": "active", "lastUpdateDate": "2018-10-25T17:27:41+08:00" } { "_id": "5bcfe3367f0xxxxx02", "type": [ "bj-nike", "sh-adidas", "th-NB", "th-vans" ], "status": "active", "lastUpdateDate": "2018-10-25T17:27:41+08:00" }
查看完整描述

1 回答

?
慕后森

TA貢獻1802條經驗 獲得超5個贊

mongoSQL:

db.inventory.find({"$or":[{type:{"$regex":"sh"}},{type:{"$regex":"bj"}}]});

SpringData Mongo:

Query qury = query.orOperator(Criteria.where("type").regex("sh"),Criteria.where("type").regex("bj"));
mongoTemplate.find(qury,entityClass);?
查看完整回答
反對 回復 2019-02-12
  • 1 回答
  • 0 關注
  • 710 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號