All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.aidensuen.mongo.executor.SimpleExecutor Maven / Gradle / Ivy

There is a newer version: 1.1.2
Show newest version
package com.github.aidensuen.mongo.executor;

import com.github.aidensuen.mongo.core.MongoDaoStatement;
import com.github.aidensuen.mongo.mapping.BoundCommand;
import com.github.aidensuen.mongo.mapping.ExampleStr;
import com.github.aidensuen.mongo.session.Configuration;
import com.github.aidensuen.mongo.util.MongoCommandUtil;
import com.mongodb.client.result.DeleteResult;
import org.springframework.data.mongodb.core.MongoOperations;
import org.springframework.data.mongodb.core.query.Query;

public class SimpleExecutor extends AbstractExecutor {

    public SimpleExecutor(Configuration configuration, MongoOperations mongoOperations) {
        super(configuration, mongoOperations);
    }

    @Override
    public DeleteResult remove(MongoDaoStatement ms, Object parameter) {
        Query query = null;
        if (parameter instanceof ExampleStr){
            query = new Query(MongoCommandUtil.buildCriteriaByExampleStr((ExampleStr)parameter));
        } else if (parameter instanceof Query){
            query = (Query) parameter;
        } else {
            BoundCommand boundCommand = ms.getBoundCommand(parameter);
            query = MongoCommandUtil.createQuery(boundCommand, ms);
        }
        return this.mongoOperations.remove(query, ms.getEntityClass());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy