mongo 批量刪除符合條件的數據(java代碼)

//七天前的數據

Bson createTimeBson = Filters.lte("creatTime",  DateTimeUtils.addSomeDay(new Date(), -7));

//in 條件

Bson parentPushTypeBson = Filters.in("parentPushType", "03","04");

//用and鏈接

Bson bson = Filters.and(createTimeBson, parentPushTypeBson);

//批量刪除

MongoUtil.getCollection("userMessage").deleteMany(bson);

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章