'Firebase Realtime database filter by child list content

I have the following Firebase Realtime database products data

{
  "-N1OHKTcbZ1h1kJQYSW-": {
    "images": [
      "image1",
      "image11"
    ],
    "name": "Tools",
  },
  "-N1OHKTdGBQ7ukjD4Hew": {
    "images": [
      "image2",

    ],
    "name": "Colors",
  },
  "-N1OHKTdGBQ7ukjD4Hex": {
    "cat": "-N1OHKR8SsG6wsOBM1ha",
    "name": "Glasses",
  },
}

I read about deep querying in docs. I can use the following to find product of name P1.

FirebaseDatabase.instance
    .ref('products')
    .orderByChild('name')
    .equalTo("P1")
    .onValue

I can get all products without images using

   FirebaseDatabase.instance
    .ref('products')
    .orderByChild('images')
    .equalTo(null)
    .onValue

How to get

  1. Products containing images
  2. Products containing certain image


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source