How to query models where relationship is null in Strapi?

System Information
  • Strapi Version: 3.5.3
  • Operating System: macOS 11.2.3
  • Database: SQLite
  • Node Version: 14.15.0
  • NPM Version: 7.6.0
  • Yarn Version: 1.22.10

I have a model Category with a belongs to many relationship with itself:

  • Category has many categories in subcategories
  • Category belongs to one category in supercategory

When I query all categories I get the correct results:

  • strapi.services.category.find()

When I query all subcategories I also get the correct results:

  • strapi.services.category.find({ supercategory_null: false })

But when I query just supercategories it doesn’t return any categories:

  • strapi.services.category.find({ supercategory_null: true })

Question

How can I query just the categories that have no supercategory relationship?

PS: if you want to earn some StackOverflow points: How to query models where relationship is null in Strapi? - Stack Overflow

2 Likes

Hello, still no answer?