{"record":{"id":"5c432590795314f6","repo":"mongodb/mongoid","slug":"errors-unsupportedjavascript-new-klass-expressio","errorCode":null,"errorMessage":"Errors::UnsupportedJavascript.new(klass, expression)","messagePattern":"Errors::UnsupportedJavascript\\.new\\(klass, expression\\)","errorType":"exception","errorClass":"Mongoid::Errors::UnsupportedJavascript","httpStatus":null,"severity":"error","filePath":"lib/mongoid/criteria.rb","lineNumber":522,"sourceCode":"    #   or javascript string.\n    #\n    # @raise [ UnsupportedJavascript ] If provided a string and the criteria\n    #   is embedded.\n    #\n    # @return [ Criteria ] The cloned selectable.\n    def where(*args)\n      # Historically this method required exactly one argument.\n      # As of https://jira.mongodb.org/browse/MONGOID-4804 it also accepts\n      # zero arguments.\n      # The underlying where implementation that super invokes supports\n      # any number of arguments, but we don't presently allow multiple\n      # arguments through this method. This API can be reconsidered in the\n      # future.\n      raise ArgumentError, \"Criteria#where requires zero or one arguments (given #{args.length})\" if args.length > 1\n\n      if args.length == 1\n        expression = args.first\n        raise Errors::UnsupportedJavascript.new(klass, expression) if expression.is_a?(::String) && embedded?\n      end\n      super\n    end\n\n    # Get a version of this criteria without the options.\n    #\n    # @example Get the criteria without options.\n    #   criteria.without_options\n    #\n    # @return [ Criteria ] The cloned criteria.\n    def without_options\n      crit = clone\n      crit.options.clear\n      crit\n    end\n\n    # Find documents by the provided javascript and scope. Uses a $where but is\n    # different from +Criteria#where+ in that it will pass a code object to the","sourceCodeStart":504,"sourceCodeEnd":540,"githubUrl":"https://github.com/mongodb/mongoid/blob/0da0e23d71adfbad31128c18e5e2c8c301c6f7c4/lib/mongoid/criteria.rb#L504-L540","documentation":"Error \"Errors::UnsupportedJavascript.new(klass, expression)\" thrown in mongodb/mongoid.","triggerScenarios":"Thrown at lib/mongoid/criteria.rb:522 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0da0e23d71adfbad31128c18e5e2c8c301c6f7c4","analyzedAt":"2026-08-23T06:25:47.656Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}