Aller au contenu principal

NoSQL Query Step

The NoSQL Query step (display name: Run NoSQL Query) executes a query or script against a NoSQL database and stores the returned document(s) in a result variable that you can assert on.

When to Use​

  • Verifying documents written to MongoDB or Azure Cosmos DB after an API operation.
  • Checking a document count or extracting an identifier to feed later steps.
  • Asserting the shape or content of a stored document.

Why: NoSQL stores are eventually consistent and are not always covered by an API response. Querying the store directly gives you ground-truth verification of persisted data.

Quickest Scenario​

  1. Add the Run NoSQL Query step to a test case.
  2. In the NoSQL Query panel, pick a project NoSQL connection profile, or click settings Configure to set the database inline.
  3. Type your query in the Query editor (e.g. { "_id": "${UserId}" }).
  4. Run the case. The JSON result appears in Query Result and is captured in the step's Result for assertions.
Query: { "_id": "${UserId}" }
Assert (Run NoSQL Query → Result contains): "active"

Configuration​

The panel shows:

  • A NoSQL connection-profile picker. When a profile is active, the inline fields are hidden.
  • A settings Configure button (visible only when no profile is active) that opens the database configuration.
  • A Query editor (code style).
  • A Query Result read-only viewer.

Connection options​

OptionDescription
Connection ProfileA project-level NoSqlConnectionProfile (type NoSql). When set, it supplies the database type and connection string and overrides the inline values.
Database TypeMongoDB or Azure Cosmos DB.
Connection StringDirect connection string — supports ${VariableName} substitution.
Database IdThe database identifier (database name under a Cosmos DB resource).
Container IdThe container/collection identifier.
remarque

For Azure Cosmos DB the Database Id and Container Id are required; for MongoDB the Container Id is the collection name.

Results​

The step returns RunResult.Success when the query runs; otherwise RunResult.Failure. The query output is exposed as:

  • QueryResult — the raw JSON document(s). For MongoDB the result uses Canonical Extended JSON; for Cosmos DB it is formatted JSON. If no document matches, the executor reports "The query does not bring any data".
  • Result — the assertion target (the DefaultAssertionTargetProperty of the step).

Because the step derives from AssertionStepBase, you can add assertions directly against Result (or QueryResult).

astuce

After editing the Query field, focus leaves the box (LostFocus) to commit the value before running.

Supported Databases​

  • MongoDB
  • Azure Cosmos DB
attention

Only MongoDB and Azure Cosmos DB are implemented. Selecting any other database type raises "Database {type} has not yet been implemented.".

See Also​