Find and filtering entries with deleteMany

System Information
  • Strapi Version: 4
  • Operating System:
  • Database:
  • Node Version:
  • NPM Version:
  • Yarn Version:

Hello everyone!

Im create a custom endpoint in order to make a bulk deletion of pages based on some field (project ID).

My service function:

'use strict';

module.exports = {
	pagesReport: async () => {
		try {

			await strapi.db.query('api::page.page').deleteMany({
				where: {
					project: {
						id: '13'
					}
				},
			});


		} catch (err) {
			return err;
		}
	}
}

As a result - nothing deleted. If I change it to:

'use strict';

module.exports = {
	pagesReport: async () => {
		try {

			await strapi.db.query('api::page.page').deleteMany({
			});


		} catch (err) {
			return err;
		}
	}
}

All pages will be deleted - so its OK and works as expected.

As a result , I think mistake inside “where” search operator that can’t find a target project id.

My Page component:

My Project component:

Example result when I get page and we can see a project ref:

Seems like its a bug, solution here works: https://github.com/strapi/strapi/issues/11998