diff --git a/modules/database/src/adapters/mongoose-adapter/MongooseSchema.ts b/modules/database/src/adapters/mongoose-adapter/MongooseSchema.ts index 1ae89b34e..b90447a18 100644 --- a/modules/database/src/adapters/mongoose-adapter/MongooseSchema.ts +++ b/modules/database/src/adapters/mongoose-adapter/MongooseSchema.ts @@ -305,15 +305,17 @@ export class MongooseSchema extends SchemaAdapter> { populate?: string[]; }, ): Promise { - let parsedQuery: Indexable | null = parseQuery(this.parseStringToQuery(query)); - parsedQuery = await this.getAuthorizedQuery( + const parsedQuery: Indexable | null = parseQuery(this.parseStringToQuery(query)); + const filter = await this.getAuthorizedQuery( 'read', parsedQuery, false, options?.userId, options?.scope, ); - if (isNil(parsedQuery)) return null; + if (isNil(filter) && !isNil(parsedQuery)) { + return null; + } let finalQuery = this.model.findOne(parsedQuery!, options?.select); if (options?.populate !== undefined && options?.populate !== null) { finalQuery = this.populate(finalQuery, options?.populate); diff --git a/modules/database/src/adapters/sequelize-adapter/SequelizeSchema.ts b/modules/database/src/adapters/sequelize-adapter/SequelizeSchema.ts index ce0578b21..682ae1646 100644 --- a/modules/database/src/adapters/sequelize-adapter/SequelizeSchema.ts +++ b/modules/database/src/adapters/sequelize-adapter/SequelizeSchema.ts @@ -339,7 +339,7 @@ export class SequelizeSchema extends SchemaAdapter> { options?.userId, options?.scope, ); - if (isNil(filter)) { + if (isNil(filter) && !isNil(query)) { return null; } const { filter: parsedFilter, parsingResult } = parseQueryFilter(