From 1213819467b0a9faad3c774c8438a22a022c291c Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Sun, 20 Aug 2017 10:16:31 +0200 Subject: [PATCH] Fixed limit issue --- CliClient/run.sh | 5 ++--- ReactNativeClient/lib/base-model.js | 2 ++ ReactNativeClient/lib/models/note.js | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CliClient/run.sh b/CliClient/run.sh index 403269014..43779cf85 100755 --- a/CliClient/run.sh +++ b/CliClient/run.sh @@ -2,6 +2,5 @@ set -e CLIENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -#bash $CLIENT_DIR/build.sh && NODE_PATH="$CLIENT_DIR/build/" node build/main.js --profile ~/Temp/TestNotes2 --stack-trace-enabled --log-level debug --env dev "$@" - -bash $CLIENT_DIR/build.sh && NODE_PATH="$CLIENT_DIR/build/" node build/main.js --stack-trace-enabled --log-level debug "$@" +bash $CLIENT_DIR/build.sh && NODE_PATH="$CLIENT_DIR/build/" node build/main.js --profile ~/Temp/TestNotes2 --stack-trace-enabled --log-level debug --env dev "$@" +#bash $CLIENT_DIR/build.sh && NODE_PATH="$CLIENT_DIR/build/" node build/main.js --stack-trace-enabled --log-level debug "$@" diff --git a/ReactNativeClient/lib/base-model.js b/ReactNativeClient/lib/base-model.js index c4623ad5d..c1cfca4b1 100644 --- a/ReactNativeClient/lib/base-model.js +++ b/ReactNativeClient/lib/base-model.js @@ -151,6 +151,8 @@ class BaseModel { params.push(pattern); } + if ('limit' in options && options.limit <= 0) return []; + let sql = 'SELECT ' + this.db().escapeFields(options.fields) + ' FROM `' + this.tableName() + '`'; if (conditions.length) sql += ' WHERE ' + conditions.join(' AND '); diff --git a/ReactNativeClient/lib/models/note.js b/ReactNativeClient/lib/models/note.js index 80a94f763..1491ba68f 100644 --- a/ReactNativeClient/lib/models/note.js +++ b/ReactNativeClient/lib/models/note.js @@ -165,6 +165,7 @@ class Note extends BaseItem { tempOptions = Object.assign({}, options); tempOptions.conditions = cond; + if ('limit' in tempOptions) tempOptions.limit -= uncompletedTodos.length; let theRest = await this.search(tempOptions); return uncompletedTodos.concat(theRest);