Cockpit icon indicating copy to clipboard operation
Cockpit copied to clipboard

Filtering on a list of nested objects does not work

Open Dorian-Vandamme opened this issue 2 years ago • 8 comments

With a structure like this:

{  "_id": "foo",
  "name": "bar",
  "list_of_ids": [
    "64c2c65384c9753d7d054c04"
  ],
  "list_of_content_link": [
    {
      "_model": "myModel",
      "_id": "64c2c654e8d2dd4142048aa1"
    }
  ]
}

If I try to filter on the list of ids like this: filter = {list_of_ids : "64c2c65384c9753d7d054c04"} The filter does work, but if I tried to filter the list of content links like this: filter = {"list_of_content_link._id" : list_of_content_link} It always returns a 404. I tried with multiple syntaxes and with mongo functions like $elemMatch but it does not work either.

Dorian-Vandamme avatar Jul 31 '23 17:07 Dorian-Vandamme

It looks like you're using MongoLite as datastorage which doesn't support all mongodb query features.

I'll mark this issue as feature request to support querieng fields in an array of documents

aheinze avatar Jul 31 '23 19:07 aheinze

No I'm using mongoDB, here is the docker image I'm using: image: mongo:4.4.6

Dorian-Vandamme avatar Aug 01 '23 13:08 Dorian-Vandamme

Did you try:


filter = {
   "list_of_content_link" : {"_id" : "64c2c65384c9753d7d054c04"}
}

?

aheinze avatar Aug 01 '23 14:08 aheinze

Yes I tried, it returns a 500 : image

Dorian-Vandamme avatar Aug 01 '23 14:08 Dorian-Vandamme

Works for me 🤔 (mongodb version 6.0.3)

image

aheinze avatar Aug 01 '23 15:08 aheinze

I upgraded my mongodb image to 6.0.3 and I still got an empty result, even if it should not :( image Might it be related to some configuration of the collection?

Dorian-Vandamme avatar Aug 01 '23 18:08 Dorian-Vandamme

Also i'm using this version of cockpit: cockpithq/cockpit:core-2.6.1

Dorian-Vandamme avatar Aug 01 '23 18:08 Dorian-Vandamme

Nevermind, I just noticed that my cockpit was not configured properly and was set to use mongolite instead of mongo.

Dorian-Vandamme avatar Aug 01 '23 19:08 Dorian-Vandamme