9 Mayıs 2018 Çarşamba

SpringData MongoDB Query Sınıfı

Giriş
Şu satırı dahil ederiz.
import org.springframework.data.mongodb.core.query.Query;
query metodu
Şu satırı dahil ederiz.
import static org.springframework.data.mongodb.core.FindAndModifyOptions.options;
import static org.springframework.data.mongodb.core.query.Criteria.where;
import static org.springframework.data.mongodb.core.query.Query.query;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoOperations;
import org.springframework.data.mongodb.core.query.Update;
Şöyle yaparız
Foo foo = mongo.findAndModify(
  query(where("_id").is(...)),
  new Update().inc("seq",1),
  options().returnNew(true).upsert(true),
  Foo.class);

Hiç yorum yok:

Yorum Gönder