Skip to content

Commit e690a17

Browse files
Copilothotlong
andcommitted
Fix indentation to match codebase standards
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 16ea08c commit e690a17

1 file changed

Lines changed: 43 additions & 43 deletions

File tree

packages/drivers/mongo/src/index.ts

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -77,51 +77,51 @@ export class MongoDriver implements Driver {
7777
let nextJoin = '$and'; // Default logic operator for next condition
7878

7979
for (const item of filters) {
80-
if (typeof item === 'string') {
81-
// Update the logic operator for the next condition
82-
if (item.toLowerCase() === 'or') {
83-
nextJoin = '$or';
84-
} else if (item.toLowerCase() === 'and') {
85-
nextJoin = '$and';
86-
}
87-
continue;
88-
}
80+
if (typeof item === 'string') {
81+
// Update the logic operator for the next condition
82+
if (item.toLowerCase() === 'or') {
83+
nextJoin = '$or';
84+
} else if (item.toLowerCase() === 'and') {
85+
nextJoin = '$and';
86+
}
87+
continue;
88+
}
8989

90-
if (Array.isArray(item)) {
91-
// Heuristic to detect if it is a criterion [field, op, value] or a nested group
92-
const [fieldRaw, op, value] = item;
93-
const isCriterion = typeof fieldRaw === 'string' && typeof op === 'string';
90+
if (Array.isArray(item)) {
91+
// Heuristic to detect if it is a criterion [field, op, value] or a nested group
92+
const [fieldRaw, op, value] = item;
93+
const isCriterion = typeof fieldRaw === 'string' && typeof op === 'string';
9494

95-
let condition: any;
96-
97-
if (isCriterion) {
98-
// This is a single criterion [field, op, value]
99-
condition = this.buildSingleCondition(fieldRaw, op, value);
100-
} else {
101-
// This is a nested group - recursively process it
102-
condition = this.buildFilterConditions(item);
103-
}
104-
105-
// Apply the join logic
106-
if (conditions.length > 0 && nextJoin === '$or') {
107-
// Collect all OR conditions together
108-
const lastItem = conditions[conditions.length - 1];
109-
if (lastItem && lastItem.$or) {
110-
// Extend existing $or array
111-
lastItem.$or.push(condition);
112-
} else {
113-
// Create new $or with previous and current condition
114-
const previous = conditions.pop();
115-
conditions.push({ $or: [previous, condition] });
116-
}
117-
} else {
118-
// Default AND - just add to conditions array
119-
conditions.push(condition);
120-
}
121-
122-
// Reset to default AND logic after processing each item
123-
nextJoin = '$and';
124-
}
95+
let condition: any;
96+
97+
if (isCriterion) {
98+
// This is a single criterion [field, op, value]
99+
condition = this.buildSingleCondition(fieldRaw, op, value);
100+
} else {
101+
// This is a nested group - recursively process it
102+
condition = this.buildFilterConditions(item);
103+
}
104+
105+
// Apply the join logic
106+
if (conditions.length > 0 && nextJoin === '$or') {
107+
// Collect all OR conditions together
108+
const lastItem = conditions[conditions.length - 1];
109+
if (lastItem && lastItem.$or) {
110+
// Extend existing $or array
111+
lastItem.$or.push(condition);
112+
} else {
113+
// Create new $or with previous and current condition
114+
const previous = conditions.pop();
115+
conditions.push({ $or: [previous, condition] });
116+
}
117+
} else {
118+
// Default AND - just add to conditions array
119+
conditions.push(condition);
120+
}
121+
122+
// Reset to default AND logic after processing each item
123+
nextJoin = '$and';
124+
}
125125
}
126126

127127
if (conditions.length === 0) return {};

0 commit comments

Comments
 (0)