You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -126,20 +135,28 @@ export default class AdminForthBaseConnector implements IAdminForthDataSourceCon
126
135
);
127
136
}
128
137
if(isPolymorphicTarget){
129
-
process.env.HEAVY_DEBUG&&console.log(`⚠️ Field '${(filtersasIAdminForthSingleFilter).field}' not found in polymorphic target resource '${resource.resourceId}', allowing query to proceed.`);
138
+
process.env.HEAVY_DEBUG&&console.log(`⚠️ Field '${filtersAsSingle.field}' not found in polymorphic target resource '${resource.resourceId}', allowing query to proceed.`);
130
139
return{ok: true,error: ''};
131
140
}else{
132
-
thrownewError(`Field '${(filtersasIAdminForthSingleFilter).field}' not found in resource '${resource.resourceId}'. ${similar ? `Did you mean '${similar}'?` : ''}`);
141
+
thrownewError(`Field '${filtersAsSingle.field}' not found in resource '${resource.resourceId}'. ${similar ? `Did you mean '${similar}'?` : ''}`);
// if "insecureRawSQL" filter is insecure sql string
156
-
if((filtersasIAdminForthSingleFilter).operator){
157
-
return{ok: false,error: `Field "operator" should not be specified in filter object alongside "insecureRawSQL": ${JSON.stringify(filters)}`};
173
+
if(filtersAsSingle.operator){
174
+
return{ok: false,error: `Field "operator" should not be specified in filter object alongside "insecureRawSQL" or "insecureRawNoSQL": ${JSON.stringify(filters)}`};
return{ok: false,error: `Field "value" should not be specified in filter object alongside "insecureRawSQL": ${JSON.stringify(filters)}`};
176
+
if(filtersAsSingle.value!==undefined){
177
+
return{ok: false,error: `Field "value" should not be specified in filter object alongside "insecureRawSQL" or "insecureRawNoSQL": ${JSON.stringify(filters)}`};
Copy file name to clipboardExpand all lines: adminforth/documentation/docs/tutorial/03-Customization/03-virtualColumns.md
+42Lines changed: 42 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -176,6 +176,48 @@ import sqlstring from 'sqlstring';
176
176
This example will allow to search for some nested field in JSONB column, however you can use any SQL query here.
177
177
178
178
179
+
### Custom Mongo queries with `insecureRawNoSQL`
180
+
181
+
For MongoDB data sources, you can inject a raw Mongo filter object via `insecureRawNoSQL`. This is useful when the built-in filters are not enough or you need dot-notation and operators not covered by AdminForth helpers.
182
+
183
+
Important: The object you provide is sent directly to MongoDB. Validate and sanitize any user inputs to prevent abuse of operators like`$where`, `$regex`, etc.
184
+
185
+
Example — filter by nested field using dot-notation:
186
+
187
+
```ts title='./resources/apartments.ts'
188
+
...
189
+
hooks: {
190
+
list: {
191
+
beforeDatasourceRequest:async ({ query, body }: { query: any, body: any }) => {
192
+
// Add raw Mongo filter: meta.is_active must equal body.is_active
After generation, you’ll see a button labeled "old image". Clicking it will open a pop-up where you can compare the generated image with the stored one:
0 commit comments