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 { 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": [