标签:
mongodb 根据_id 查询记录:
public Price queryPriceById(String id) throws Exception { return mongoTemplate.findById(new ObjectId(id), Price.class, PRICE_COLLECTION); }
根据集合中的某个字段查询:
public Price queryPriceByName(String name) throws Exception { Price price = null; price = mongoTemplate.findOne(new Query(Criteria.where("name").is(name)), Price.class, PRICE_COLLECTION); return price; }
标签:
原文地址:http://www.cnblogs.com/z360519549/p/5840872.html