Skip to content

πŸ”₯ πŸ”₯ πŸ”₯ A Free & Self-hostable Airtable Alternative

fix: use xc condition

DarkPhoenix27042248d43ab549
diff --git a/packages/nocodb/src/meta/meta.service.ts b/packages/nocodb/src/meta/meta.service.ts
index 1a0abc514d..f0ba195813 100644
--- a/packages/nocodb/src/meta/meta.service.ts
+++ b/packages/nocodb/src/meta/meta.service.ts
@@ -495,24 +495,23 @@ export class MetaService {
* Get order value for the next record
* @param target - Table name
* @param condition - Condition to be applied
+ * @param xcCondition - Additional nested or complex condition to be added to the query.
* @returns {Promise<number>} - Order value
* */
public async metaGetNextOrder(
target: string,
condition: { [key: string]: any },
+ xcCondition?: Condition,
): Promise<number> {
const query = this.knexConnection(target);
- if (!condition) {
- condition = {};
+ if (condition) {
+ query.where(condition);
+ }
+
+ if (xcCondition) {
+ (query as any).condition(xcCondition);
}
- Object.entries(condition).forEach(([key, value]) => {
- if (Array.isArray(value)) {
- query.whereIn(key, value);
- } else {
- query.where(key, value);
- }
- });
query.max('order', { as: 'order' });