package com.fdkankan.mongodb.service;

import com.fdkankan.mongodb.base.MongoPageResult;
import com.fdkankan.mongodb.base.BaseRequestMongo;
import com.mongodb.client.result.DeleteResult;
import com.mongodb.client.result.UpdateResult;
import org.springframework.data.geo.GeoResults;
import org.springframework.data.mongodb.core.query.NearQuery;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.data.util.Pair;

import java.util.List;

/**
 * @author Xiewj
 * @date 2021/11/15
 * Mongodb工具类
 */
 public interface MongodbBaseService<T>  {
     MongoPageResult<T> pageQuery(BaseRequestMongo page, Query query);

    long getCount(Query query);

    T save(T t);

    T insert(T t);


     DeleteResult delete(T t);

     DeleteResult deleteById(Object id);

     DeleteResult delete(Query query);

    T update(T t);

     T findById(Object id);

     List<T> findAll();

     List<T> find(Query query);

    GeoResults<T> geoNear(NearQuery query);

    T findOne(Query query);

     boolean exists(Query query);

     boolean exists(T t);

     boolean exitsById(Object id);

     long count(Query query);

     Class<T> getTClass();

     Pair<String, Object> extractIdPropertyAndValue(Object object);

     Query getIdQueryFor(Object object);

     UpdateResult updateFirst(Query query, Update update);

}
