接口 DatabaseService


  • public interface DatabaseService
    Mongo database service.

    TODO: refine APIs like *One, *Many, find*.

    • 方法概要

      所有方法 实例方法 抽象方法 
      修饰符和类型 方法 说明
      java.util.concurrent.CompletableFuture<java.lang.Long> countDocuments​(java.lang.String collection, com.fasterxml.jackson.databind.JsonNode query, CountOptions options)
      Count documents.
      java.util.concurrent.CompletableFuture<java.lang.Void> createCollection​(java.lang.String name)
      Lets the vault owner create a collection on database.
      java.util.concurrent.CompletableFuture<java.lang.Void> deleteCollection​(java.lang.String name)
      Lets the vault owner delete a collection on database according to collection name.
      java.util.concurrent.CompletableFuture<java.lang.Void> deleteMany​(java.lang.String collection, com.fasterxml.jackson.databind.JsonNode filter)
      Delete many existing documents in a given collection.
      java.util.concurrent.CompletableFuture<java.lang.Void> deleteOne​(java.lang.String collection, com.fasterxml.jackson.databind.JsonNode filter)
      Delete an existing document in a given collection.
      java.util.concurrent.CompletableFuture<java.util.List<com.fasterxml.jackson.databind.JsonNode>> findMany​(java.lang.String collection, com.fasterxml.jackson.databind.JsonNode query, FindOptions options)
      Find many documents.
      java.util.concurrent.CompletableFuture<com.fasterxml.jackson.databind.JsonNode> findOne​(java.lang.String collection, com.fasterxml.jackson.databind.JsonNode query, FindOptions options)
      Find a specific document.
      java.util.concurrent.CompletableFuture<java.util.List<Collection>> getCollections()
      Get all user collections.
      java.util.concurrent.CompletableFuture<InsertResult> insertMany​(java.lang.String collection, java.util.List<com.fasterxml.jackson.databind.JsonNode> docs, InsertOptions options)
      Insert many new documents in a given collection.
      java.util.concurrent.CompletableFuture<InsertResult> insertOne​(java.lang.String collection, com.fasterxml.jackson.databind.JsonNode doc, InsertOptions options)
      Insert a new document in a given collection.
      java.util.concurrent.CompletableFuture<java.util.List<com.fasterxml.jackson.databind.JsonNode>> query​(java.lang.String collection, com.fasterxml.jackson.databind.JsonNode query, QueryOptions options)
      Find many documents by many options.
      java.util.concurrent.CompletableFuture<UpdateResult> updateMany​(java.lang.String collection, com.fasterxml.jackson.databind.JsonNode filter, com.fasterxml.jackson.databind.JsonNode update, UpdateOptions options)
      Update many existing documents in a given collection.
      java.util.concurrent.CompletableFuture<UpdateResult> updateOne​(java.lang.String collection, com.fasterxml.jackson.databind.JsonNode filter, com.fasterxml.jackson.databind.JsonNode update, UpdateOptions options)
      Update an existing document in a given collection.
    • 方法详细资料

      • createCollection

        java.util.concurrent.CompletableFuture<java.lang.Void> createCollection​(java.lang.String name)
        Lets the vault owner create a collection on database.
        参数:
        name - the collection name
        返回:
        fail(false) or success(true)
      • deleteCollection

        java.util.concurrent.CompletableFuture<java.lang.Void> deleteCollection​(java.lang.String name)
        Lets the vault owner delete a collection on database according to collection name.
        参数:
        name - the collection name
        返回:
        fail(false) or success(true)
      • getCollections

        java.util.concurrent.CompletableFuture<java.util.List<Collection>> getCollections()
        Get all user collections.
        返回:
        fail(false) or success(true)
      • insertOne

        java.util.concurrent.CompletableFuture<InsertResult> insertOne​(java.lang.String collection,
                                                                       com.fasterxml.jackson.databind.JsonNode doc,
                                                                       InsertOptions options)
        Insert a new document in a given collection.
        参数:
        collection - the collection name
        doc - The document to insert. Must be a mutable mapping type. If the document does not have an _id field one will be added automatically
        options - bypass_document_validation: (optional) If True, allows the write to opt-out of document level validation. Default is False.
        返回:
        Results returned by InsertResult wrapper
      • insertMany

        java.util.concurrent.CompletableFuture<InsertResult> insertMany​(java.lang.String collection,
                                                                        java.util.List<com.fasterxml.jackson.databind.JsonNode> docs,
                                                                        InsertOptions options)
        Insert many new documents in a given collection.
        参数:
        collection - the collection name
        docs - The document to insert. Must be a mutable mapping type. If the document does not have an _id field one will be added automatically.
        options - ordered (optional): If True (the default) documents will be inserted on the server serially, in the order provided. If an error occurs all remaining inserts are aborted. If False, documents will be inserted on the server in arbitrary order, possibly in parallel, and all document inserts will be attempted. bypass_document_validation: (optional) If True, allows the write to opt-out of document level validation. Default is False.
        返回:
        Results returned by InsertResult wrapper
      • countDocuments

        java.util.concurrent.CompletableFuture<java.lang.Long> countDocuments​(java.lang.String collection,
                                                                              com.fasterxml.jackson.databind.JsonNode query,
                                                                              CountOptions options)
        Count documents.
        参数:
        collection - the collection name
        query - The document of filter
        options - skip (int): The number of matching documents to skip before returning results. limit (int): The maximum number of documents to count. Must be a positive integer. If not provided, no limit is imposed. maxTimeMS (int): The maximum amount of time to allow this operation to run, in milliseconds.
        返回:
        count size
      • findOne

        java.util.concurrent.CompletableFuture<com.fasterxml.jackson.databind.JsonNode> findOne​(java.lang.String collection,
                                                                                                com.fasterxml.jackson.databind.JsonNode query,
                                                                                                FindOptions options)
        Find a specific document.
        参数:
        collection - the collection name
        query - optional, a JSON object specifying elements which must be present for a document to be included in the result set
        options - optional,refer to FindOptions
        返回:
        a JSON object document result
      • findMany

        java.util.concurrent.CompletableFuture<java.util.List<com.fasterxml.jackson.databind.JsonNode>> findMany​(java.lang.String collection,
                                                                                                                 com.fasterxml.jackson.databind.JsonNode query,
                                                                                                                 FindOptions options)
        Find many documents.
        参数:
        collection - the collection name
        query - optional, a JSON object specifying elements which must be present for a document to be included in the result set
        options - optional,refer to FindOptions
        返回:
        a JsonNode array result of document
      • query

        java.util.concurrent.CompletableFuture<java.util.List<com.fasterxml.jackson.databind.JsonNode>> query​(java.lang.String collection,
                                                                                                              com.fasterxml.jackson.databind.JsonNode query,
                                                                                                              QueryOptions options)
        Find many documents by many options.
        参数:
        collection - the collection name
        query - optional, a JSON object specifying elements which must be present for a document to be included in the result set
        options - optional,refer to QueryOptions
        返回:
        a JsonNode array result of document
      • updateOne

        java.util.concurrent.CompletableFuture<UpdateResult> updateOne​(java.lang.String collection,
                                                                       com.fasterxml.jackson.databind.JsonNode filter,
                                                                       com.fasterxml.jackson.databind.JsonNode update,
                                                                       UpdateOptions options)
        Update an existing document in a given collection.
        参数:
        collection - the collection name
        filter - A query that matches the document to update.
        update - The modifications to apply.
        options - optional, refer to UpdateOptions
        返回:
        Results returned by UpdateResult wrapper
      • updateMany

        java.util.concurrent.CompletableFuture<UpdateResult> updateMany​(java.lang.String collection,
                                                                        com.fasterxml.jackson.databind.JsonNode filter,
                                                                        com.fasterxml.jackson.databind.JsonNode update,
                                                                        UpdateOptions options)
        Update many existing documents in a given collection.
        参数:
        collection - the collection name
        filter - A query that matches the document to update.
        update - The modifications to apply.
        options - optional, refer to UpdateOptions
        返回:
        Results returned by UpdateResult wrapper
      • deleteOne

        java.util.concurrent.CompletableFuture<java.lang.Void> deleteOne​(java.lang.String collection,
                                                                         com.fasterxml.jackson.databind.JsonNode filter)
        Delete an existing document in a given collection.
        参数:
        collection - the collection name
        filter - A query that matches the document to delete.
        返回:
        Delete result
      • deleteMany

        java.util.concurrent.CompletableFuture<java.lang.Void> deleteMany​(java.lang.String collection,
                                                                          com.fasterxml.jackson.databind.JsonNode filter)
        Delete many existing documents in a given collection.
        参数:
        collection - the collection name
        filter - A query that matches the document to delete.
        返回:
        Delete result