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

apoc.mongodb.MongoDbCollInterface Maven / Gradle / Ivy

package apoc.mongodb;

import apoc.util.Util;
import org.bson.Document;

import java.io.Closeable;
import java.util.List;
import java.util.Map;
import java.util.stream.Stream;

public interface MongoDbCollInterface extends Closeable {
    Map first(Map params);

    Stream> all(Map query, Long skip, Long limit);

    long count(Map query);
    long count(Document query);

    Stream> aggregate(List pipeline);

    Stream> find(Map query, Map project, Map sort, Long skip, Long limit);
    Stream> find(Document query, Document project, Document sort, int skip, int limit);

    void insert(List> docs);
    void insertDocs(List docs);

    long update(Map query, Map update);
    long update(Document query, Document update);

    long delete(Map query);
    long delete(Document query);

    default void safeClose() {
        Util.close(this);
    }

    class Factory {
        public static MongoDbCollInterface create(String url, String db, String coll, boolean compatibleValues,
                                  boolean extractReferences,
                                  boolean objectIdAsMap) {
            try {
                return new MongoDBColl(url, db, coll, compatibleValues, extractReferences, objectIdAsMap);
            } catch (Exception e) {
                throw new RuntimeException("Could not create MongoDBColl instance", e);
            }
        }

        public static MongoDbCollInterface create(String url, MongoDbConfig conf) {
            try {
                return new MongoDBColl(url, conf);
            } catch (Exception e) {
                throw new RuntimeException("Could not create MongoDBColl instance", e);
            }
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy