Package com.c8db

Interface C8Database

    • Method Detail

      • c8db

        C8DB c8db()
        Return the main entry point for the C8DB driver
        Returns:
        main entry point
      • tenant

        String tenant()
        Returns the name of the tenant
        Returns:
        tenant name
      • name

        String name()
        Returns the name of the database
        Returns:
        database name
      • exists

        boolean exists()
                throws C8DBException
        Checks whether the database exists
        Returns:
        true if the database exists, otherwise false
        Throws:
        C8DBException
      • getAccessibleGeoFabrics

        Collection<String> getAccessibleGeoFabrics()
                                            throws C8DBException
        Retrieves a list of all databases the current user can access
        Returns:
        a list of all databases the current user can access
        Throws:
        C8DBException
      • collection

        C8Collection collection​(String name)
        Returns a ArangoCollection instance for the given collection name.
        Parameters:
        name - Name of the collection
        Returns:
        collection handler
      • createCollection

        CollectionEntity createCollection​(String name)
                                   throws C8DBException
        Creates a collection for the given collection's name, then returns collection information from the server.
        Parameters:
        name - The name of the collection
        Returns:
        information about the collection
        Throws:
        C8DBException
      • createCollection

        CollectionEntity createCollection​(String name,
                                          CollectionCreateOptions options)
                                   throws C8DBException
        Creates a collection with the given options for this collection's name, then returns collection information from the server.
        Parameters:
        name - The name of the collection
        options - Additional options, can be null
        Returns:
        information about the collection
        Throws:
        C8DBException
      • grantAccess

        void grantAccess​(String user,
                         Permissions permissions)
                  throws C8DBException
        Grants or revoke access to the database for user user. You need permission to the _system database in order to execute this call.
        Parameters:
        user - The name of the user
        permissions - The permissions the user grant
        Throws:
        C8DBException
        See Also:
        API Documentation
      • grantAccess

        void grantAccess​(String user)
                  throws C8DBException
        Grants access to the database for user user. You need permission to the _system database in order to execute this call.
        Parameters:
        user - The name of the user
        Throws:
        C8DBException
        See Also:
        API Documentation
      • revokeAccess

        void revokeAccess​(String user)
                   throws C8DBException
        Revokes access to the database dbname for user user. You need permission to the _system database in order to execute this call.
        Parameters:
        user - The name of the user
        Throws:
        C8DBException
      • resetAccess

        void resetAccess​(String user)
                  throws C8DBException
        Clear the database access level, revert back to the default access level.
        Parameters:
        user - The name of the user
        Throws:
        C8DBException
        Since:
        ArangoDB 3.2.0
        See Also:
        API Documentation
      • query

        <T> C8Cursor<T> query​(String query,
                              Map<String,​Object> bindVars,
                              C8qlQueryOptions options,
                              Class<T> type)
                       throws C8DBException
        Performs a database query using the given query and bindVars, then returns a new C8Cursor instance for the result list.
        Parameters:
        query - A C8QL query string
        bindVars - key/value pairs defining the variables to bind the query to
        options - Additional options that will be passed to the query API, can be null
        type - The type of the result (POJO class, VPackSlice, String for JSON, or Collection/List/Map)
        Returns:
        cursor of the results
        Throws:
        C8DBException
        See Also:
        API Documentation
      • query

        <T> C8Cursor<T> query​(String query,
                              C8qlQueryOptions options,
                              Class<T> type)
                       throws C8DBException
        Performs a database query using the given query, then returns a new ArangoCursor instance for the result list.
        Parameters:
        query - An AQL query string
        options - Additional options that will be passed to the query API, can be null
        type - The type of the result (POJO class, VPackSlice, String for JSON, or Collection/List/Map)
        Returns:
        cursor of the results
        Throws:
        C8DBException
        See Also:
        API Documentation
      • query

        <T> C8Cursor<T> query​(String query,
                              Map<String,​Object> bindVars,
                              Class<T> type)
                       throws C8DBException
        Performs a database query using the given query and bindVars, then returns a new ArangoCursor instance for the result list.
        Parameters:
        query - An AQL query string
        bindVars - key/value pairs defining the variables to bind the query to
        type - The type of the result (POJO class, VPackSlice, String for JSON, or Collection/List/Map)
        Returns:
        cursor of the results
        Throws:
        C8DBException
        See Also:
        API Documentation
      • query

        <T> C8Cursor<T> query​(String query,
                              Class<T> type)
                       throws C8DBException
        Performs a database query using the given query, then returns a new ArangoCursor instance for the result list.
        Parameters:
        query - An AQL query string
        type - The type of the result (POJO class, VPackSlice, String for JSON, or Collection/List/Map)
        Returns:
        cursor of the results
        Throws:
        C8DBException
        See Also:
        API Documentation
      • cursor

        <T> C8Cursor<T> cursor​(String cursorId,
                               Class<T> type)
                        throws C8DBException
        Return an cursor from the given cursor-ID if still existing
        Parameters:
        cursorId - The ID of the cursor
        type - The type of the result (POJO class, VPackSlice, String for JSON, or Collection/List/Map)
        Returns:
        cursor of the results
        Throws:
        C8DBException
        See Also:
        API Documentation
      • graph

        C8Graph graph​(String name)
        Returns a ArangoGraph instance for the given graph name.
        Parameters:
        name - Name of the graph
        Returns:
        graph handler
      • createGraph

        GraphEntity createGraph​(String name,
                                Collection<EdgeDefinition> edgeDefinitions)
                         throws C8DBException
        Create a new graph in the graph module. The creation of a graph requires the name of the graph and a definition of its edges.
        Parameters:
        name - Name of the graph
        edgeDefinitions - An array of definitions for the edge
        Returns:
        information about the graph
        Throws:
        C8DBException
        See Also:
        API Documentation
      • restql

        Restql restql()
        Returns a Restql instance.
        Returns:
        Restql handler
      • transaction

        <T> T transaction​(String action,
                          Class<T> type,
                          C8TransactionOptions options)
                   throws C8DBException
        Performs a server-side transaction and returns its return value.
        Parameters:
        action - A String evaluating to a JavaScript function to be executed on the server.
        type - The type of the result (POJO class, VPackSlice or String for JSON)
        options - Additional options, can be null
        Returns:
        the result of the transaction if it succeeded
        Throws:
        C8DBException
      • executeTraversal

        <V,​E> TraversalEntity<V,​E> executeTraversal​(Class<V> vertexClass,
                                                                Class<E> edgeClass,
                                                                TraversalOptions options)
                                                         throws C8DBException
        Execute a server-side traversal
        Parameters:
        vertexClass - The type of the vertex documents (POJO class, VPackSlice or String for JSON)
        edgeClass - The type of the edge documents (POJO class, VPackSlice or String for JSON)
        options - Additional options
        Returns:
        Result of the executed traversal
        Throws:
        C8DBException
        See Also:
        API Documentation
      • getDocument

        <T> T getDocument​(String id,
                          Class<T> type)
                   throws C8DBException
        Reads a single document
        Parameters:
        id - The id of the document
        type - The type of the document (POJO class, VPackSlice or String for JSON)
        Returns:
        the document identified by the id
        Throws:
        C8DBException
        See Also:
        API Documentation
      • getDocument

        <T> T getDocument​(String id,
                          Class<T> type,
                          DocumentReadOptions options)
                   throws C8DBException
        Reads a single document
        Parameters:
        id - The id of the document
        type - The type of the document (POJO class, VPackSlice or String for JSON)
        options - Additional options, can be null
        Returns:
        the document identified by the id
        Throws:
        C8DBException
      • stream

        C8Stream stream​(String name)
        Returns a C8Stream instance for the given stream name.
        Parameters:
        name - Name of the stream
        Returns:
        stream handler
      • createPersistentStream

        void createPersistentStream​(String name,
                                    C8StreamCreateOptions options)
                             throws C8DBException
        Create asynchronously a persistent stream for a given fabric.
        Parameters:
        name - of the stream
        options - C8StreamCreateOptions
        Throws:
        C8DBException
      • clearBacklog

        void clearBacklog()
        Clear backlog for all streams on a stream db.
      • clearBacklog

        void clearBacklog​(String subscriptionName)
        Clear backlog for given subscription.
        Parameters:
        subscriptionName - Name of the subscription
      • unsubscribe

        void unsubscribe​(String subscriptionName)
        Unsubscribes the given subscription on all streams on a stream db.
        Parameters:
        subscriptionName - Identifying name of the subscripton.
      • createUserQuery

        UserQueryEntity createUserQuery​(UserQueryOptions userQueryDefinition,
                                        String user)
                                 throws C8DBException
        Creates user query as a given user.

        Note: this can only be invoked by a admin user.

        Parameters:
        userQueryDefinition - user query definition.
        user - user name.
        Returns:
        user query entity.
        Throws:
        C8DBException
      • executeUserQuery

        <T> C8Cursor<T> executeUserQuery​(String userName,
                                         String name,
                                         Map<String,​Object> bindVars,
                                         Class<T> type)
                                  throws C8DBException
        Executes a saved using query using the given name and bindVars, then returns a new C8Cursor instance for the result list. If userName is null then tries to execute it for current user.
        Parameters:
        userName - user the query belongs to. If null executes it for current user
        name - A user query name
        bindVars - key/value pairs defining the variables to bind the query to
        type - The type of the result (POJO class, VPackSlice, String for JSON, or Collection/List/Map)
        Returns:
        cursor of the results
        Throws:
        C8DBException
      • admin

        C8Admin admin()
        Returns a C8Admin instance.
        Returns:
        C8Admin handler
      • apiKeys

        C8ApiKeys apiKeys()
        Returns a C8ApiKeys instance.
        Returns:
        C8ApiKeys handler