125 — CommandFailed

queryconfiguration

The command cannot be executed against a view

What is happening?

CommandNotSupportedOnView is returned when a command that only works on regular collections is run against a view. Views are read-only stored aggregation pipelines. Write operations (insert, update, delete), index operations (createIndex, dropIndex), and certain administrative commands (compact, validate) are not supported on views.

Common causes

  1. Attempting to insert, update, or delete documents on a view
  2. Trying to create or drop an index on a view
  3. Running compact, validate, or reIndex against a view
  4. Application code not distinguishing between collections and views

Source code references

ErrorCodes::CommandFailed found in 34 locations in the MongoDB server source.

Diagnostic Steps

Related Issues