Commands Overview


  • RavenDB's Client API is structured in layers.
    At the highest layer, you interact with the document store and the document session,
    which handle most common database tasks like loading, saving, and querying documents.

  • Beneath this high-level interface are Operations and Commands:

    • Operations:

      • Operations provide management functionality outside the session's context,
        like creating a database, performing bulk actions, or managing server-wide configurations.

      • Learn more about Operations in what are Operations.

    • Commands:

      • All high-level methods and Operations are built on top of Commands.
        Commands form the lowest-level operations that directly communicate with the server.

      • For example, a session’s Load method translates internally to a LoadOperation,
        which ultimately relies on a GetDocumentsCommand to fetch data from the server.

      • Commands are responsible for sending the appropriate request to the server using a Request Executor,
        and parsing the server's response.

      • All commands can be executed using either the Store's Request Executor or the Session's Request Executor,
        regardless of whether the command is session-related or not.

  • This layered structure lets you work at any level, depending on your needs.

  • In this page:


Examples

GetDocumentsCommand

try (IDocumentSession session = store.openSession()) {
    GetDocumentsCommand command = new GetDocumentsCommand("orders/1-A", null, false);
    session.advanced().getRequestExecutor().execute(command);
    ObjectNode order = (ObjectNode) command.getResult().getResults().get(0);
}

DeleteDocumentCommand

try (IDocumentSession session = store.openSession()) {
    DeleteDocumentCommand command = new DeleteDocumentCommand("employees/1-A", null);
    session.advanced().getRequestExecutor().execute(command);
}

Available commands

  • The Following low-level commands are available:
    • ConditionalGetDocumentsCommand
    • CreateSubscriptionCommand
    • DeleteDocumentCommand
    • DeleteSubscriptionCommand
    • DropSubscriptionConnectionCommand
    • ExplainQueryCommand
    • GetClusterTopologyCommand
    • GetConflictsCommand
    • GetDatabaseTopologyCommand
    • GetDocumentsCommand
    • GetIdentitiesCommand
    • GetNextOperationIdCommand
    • GetNodeInfoCommand
    • GetOperationStateCommand
    • GetRawStreamResultCommand
    • GetRevisionsBinEntryCommand
    • GetRevisionsCommand
    • GetSubscriptionsCommand
    • GetSubscriptionStateCommand
    • GetTcpInfoCommand
    • GetTrafficWatchConfigurationCommand
    • HeadAttachmentCommand
    • HeadDocumentCommand
    • HiLoReturnCommand
    • IsDatabaseLoadedCommand
    • KillOperationCommand
    • MultiGetCommand
    • NextHiLoCommand
    • NextIdentityForCommand
    • PutDocumentCommand
    • PutSecretKeyCommand
    • QueryCommand
    • QueryStreamCommand
    • SeedIdentityForCommand
    • SingleNodeBatchCommand
    • WaitForRaftIndexCommand

Syntax

public <TResult> void execute(RavenCommand<TResult> command);

public <TResult> void execute(RavenCommand<TResult> command, SessionInfo sessionInfo);