gid-oss / dataui-nestjs-crud

NestJs CRUD for RESTful APIs
https://github.com/nestjsx/crud/wiki
MIT License
130 stars 31 forks source link

Feature Request: Join Filter (ON clause) #38

Closed ZaidMaslouhi closed 7 months ago

ZaidMaslouhi commented 8 months ago

Current Functionality:

NestJS CRUD currently allows for joining related entities in queries. However, there is limited control over the join condition itself.

Request:

This feature request proposes the addition of join filters, allowing users to specify a WHERE condition within the ON clause of a join.

Benefits:

Implementation:

Introduce a new property within the QueryJoin type of crud-request. This property could be named on and accept array of objects of type QueryFilter representing the WHERE condition for the join.

Example:

export declare type QueryJoin = {
  field: string;
  select?: QueryField[];
  on?: QueryFilter[]; // New property
};

This functionality would allow users to specify conditions within the join, like so:

query.setJoin({
    field: 'author',
    select: ['name', 'image'],
    on: [{ field: 'author.id', operator: 'eq', value: 123 }], // Filter by specific author ID
});

By implementing join filters, dataui-nestjs-crud would provide greater control over join conditions, enabling more sophisticated data retrieval scenarios.

zaro commented 7 months ago

@ZaidMaslouhi Thank you for the contribution. PR was just merged and the new 5.3.4 release includes it.

ZaidMaslouhi commented 7 months ago

You are welcome! glad to see it in 5.3.4 🚀