national-gold
national-gold2mo ago

Missing case "nnull" operator of nestjsx-crud provider

mapOperator missing case nnull
4 Replies
kapa.ai
kapa.ai2mo ago
Hi @tingadev. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- It appears that the nnull operator is not currently mapped in the mapOperator utility for the nestjsx-crud provider in refine. This issue has been identified and discussed in the refine community. Steps to Address the Issue 1. Identify the Missing Mapping: According to the Github Issue #4805 (https://github.com/refinedev/refine/issues/4805), the nnull operator is not mapped in the mapOperator utility. You can see the relevant part of the discussion here (https://github.com/refinedev/refine/issues/4805). 2. Implementation Suggestion: The nestjsx-crud supports the nnull operator, and it can be implemented using the CondOperator.NOT_NULL utility. This was confirmed by a contributor in the same issue. 3. Contributing to Refine: If you would like to contribute to refine by adding this feature, the team is open to contributions and willing to help you through the process. Example Code Here is a conceptual example of how you might add the nnull operator to the mapOperator utility:
// mapOperator.ts
import { CondOperator } from '@nestjsx/crud-request';
const mapOperator = (operator: string) => {
switch (operator) {
case 'eq':
return CondOperator.EQUALS;
case 'ne':
return CondOperator.NOT_EQUALS;
case 'lt':
return CondOperator.LOWER_THAN;
case 'gt':
return CondOperator.GREATER_THAN;
case 'lte':
return CondOperator.LOWER_THAN_EQUALS;
case 'gte':
return CondOperator.GREATER_THAN_EQUALS;
case 'in':
return CondOperator.IN;
case 'nin':
return CondOperator.NOT_IN;
case 'contains':
return CondOperator.CONTAINS;
case 'ncontains':
return CondOperator.NOT_CONTAINS;
case 'between':
return CondOperator.BETWEEN;
case 'nbetween':
return CondOperator.NOT_BETWEEN;
case 'null':
return CondOperator.IS_NULL;
case 'nnull':
return CondOperator.NOT_NULL; // Add this line
// Add other cases as needed
default:
throw new Error(`Unknown operator: ${operator}`);
}
};
// mapOperator.ts
import { CondOperator } from '@nestjsx/crud-request';
const mapOperator = (operator: string) => {
switch (operator) {
case 'eq':
return CondOperator.EQUALS;
case 'ne':
return CondOperator.NOT_EQUALS;
case 'lt':
return CondOperator.LOWER_THAN;
case 'gt':
return CondOperator.GREATER_THAN;
case 'lte':
return CondOperator.LOWER_THAN_EQUALS;
case 'gte':
return CondOperator.GREATER_THAN_EQUALS;
case 'in':
return CondOperator.IN;
case 'nin':
return CondOperator.NOT_IN;
case 'contains':
return CondOperator.CONTAINS;
case 'ncontains':
return CondOperator.NOT_CONTAINS;
case 'between':
return CondOperator.BETWEEN;
case 'nbetween':
return CondOperator.NOT_BETWEEN;
case 'null':
return CondOperator.IS_NULL;
case 'nnull':
return CondOperator.NOT_NULL; // Add this line
// Add other cases as needed
default:
throw new Error(`Unknown operator: ${operator}`);
}
};
Additional Resources - CrudOperators Documentation (https://refine.dev/docs/core/interface-references/#crudoperators) - nestjsx-crud Filter Conditions (https://github.com/nestjsx/crud/wiki/Requests#filter-conditions) If you need further assistance, you can always refer to the refine documentation (https://refine.dev/docs) or reach out to the community for support. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2mo ago
<@761921731505946634> kapa.ai is still learning and improving, please let us know how it did by reacting below
national-gold
national-gold2mo ago
thanks
national-gold
national-gold2mo ago
good jobs !