From 4729ceb2e9302f23c7843b33d56225efba5716d2 Mon Sep 17 00:00:00 2001 From: Ryan Kotzen Date: Thu, 5 Jun 2025 18:35:56 +0200 Subject: [PATCH 1/2] adding the ability to not auto set limit 100 --- lib/make/index.js | 4 +--- lib/types.ts | 2 ++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/make/index.js b/lib/make/index.js index 67d8af0..b175c43 100644 --- a/lib/make/index.js +++ b/lib/make/index.js @@ -8,7 +8,6 @@ const arraySequenceIndexOf = require('../arraySequenceIndexOf'); const lodash = require('lodash'); /** * Parses a sql statement into a mongo aggregate pipeline - * * @param {import('../types').ParserInput} sqlOrAST - The sql to make into an aggregate * @param {import('../types').ParserOptions} [options] - the parser options * @param {import('../types').NoqlContext} [context] - The Noql context to use when generating the output @@ -57,7 +56,6 @@ function makeMongoAggregate(sqlOrAST, options = {unwindJoins: false}, context) { } /** * Converts a SQL statement to a mongo query. - * * @param {import('../types').ParserInput} sqlOrAST - the SQL statement or AST to parse * @param {import('../types').ParserOptions} [options] - the parser options * @param {import('../types').NoqlContext} [context] - The Noql context to use when generating the output @@ -78,7 +76,7 @@ function makeMongoQuery(sqlOrAST, options = {}, context) { const result = createResultObject(); /** @type{import('../types').ParsedMongoQuery} */ const parsedQuery = { - limit: 100, + limit: options.noDefaultLimit ? undefined : 100, collection: ast.from[0].table, type: 'query', }; diff --git a/lib/types.ts b/lib/types.ts index 7ff9c0a..27ff0ea 100644 --- a/lib/types.ts +++ b/lib/types.ts @@ -192,6 +192,8 @@ export interface ParserOptions { schemas?: Schemas; /** If true, will optimize the join for better performance */ optimizeJoins?: boolean; + /** No default limit, default is 100. If false or undefined, the default limit will be used */ + noDefaultLimit?: boolean; } export interface NoqlContext extends ParserOptions { From d2e4c8d95af6a8d01029fb656fbfc4659becc278 Mon Sep 17 00:00:00 2001 From: Ryan Kotzen Date: Thu, 5 Jun 2025 19:24:07 +0200 Subject: [PATCH 2/2] 5.0.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9bef369..c44fe89 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@synatic/noql", - "version": "5.0.1", + "version": "5.0.2", "description": "Convert SQL statements to mongo queries or aggregates", "main": "index.js", "files": [