Skip to content

Using exists operator on an array type field in mongo #15109

@AndreasHart

Description

@AndreasHart

Describe the Bug

When you use an exists operator on an array type field on a mongo db it throws an error saying "Parameter "obj" to Document() must be an object, got "" (type string) mongo" .

If this is not expected behaviour I am happy to take a pass at fixing.

Link to the code that reproduces this issue

https://github.com/AndreasHart/payload-cms-array-exists

Reproduction Steps

Use exists operator on an array type value.

Which area(s) are affected?

db: mongodb

Environment Info

Binaries:
  Node: 22.21.1
  npm: 10.9.4
  Yarn: N/A
  pnpm: 10.24.0
Relevant Packages:
  payload: 3.66.0
  @payloadcms/db-mongodb: 3.66.0
  @payloadcms/translations: 3.66.0
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.6.0: Mon Aug 11 21:16:34 PDT 2025; root:xnu-11417.140.69.701.11~1/RELEASE_ARM64_T6020
  Available memory (MB): 32768
  Available CPU cores: 12

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions