From fe1ab5f85807e181243c331ecfcfd3bcab797a32 Mon Sep 17 00:00:00 2001 From: Benjamin Pannell Date: Fri, 30 Oct 2015 15:39:57 +0200 Subject: [PATCH 1/5] feat: Added readFrom method to cursor Allows you to specify the read preference for a cursor. --- lib/Cursor.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/Cursor.ts b/lib/Cursor.ts index 99f23d9..3221ea4 100644 --- a/lib/Cursor.ts +++ b/lib/Cursor.ts @@ -145,4 +145,13 @@ export class Cursor { skip(skip: number): Cursor { return new Cursor(this.model, this.conditions, this.cursor.skip(skip)); } + + /** + * Returns a new cursor which will read from the specified node type. + * @param {String} type The type of node to read from - see https://docs.mongodb.org/manual/core/read-preference/ + * @return {Cursor} The new cursor which reads from the specified node type + */ + readFrom(type: string): Cursor { + return new Cursor(this.model, this.conditions, this.cursor.setReadPreference(type)); + } } \ No newline at end of file From 17edecd92931d6693f61ddb8da826258fca78575 Mon Sep 17 00:00:00 2001 From: Benjamin Pannell Date: Fri, 30 Oct 2015 15:40:21 +0200 Subject: [PATCH 2/5] feat: Added one() method to cursor to read a single item from the database --- lib/Cursor.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/Cursor.ts b/lib/Cursor.ts index 3221ea4..d04cc35 100644 --- a/lib/Cursor.ts +++ b/lib/Cursor.ts @@ -109,6 +109,30 @@ export class Cursor { }).nodeify(callback); } + /** + * Retrieves the next item in the result list and then closes the cursor + * @param {function(Error, TInstance)} callback A callback which is triggered when the next item becomes available + * @return {Promise} A promise which is resolved once the item becomes available and the cursor has been closed. + */ + one(callback?: General.Callback): Bluebird { + return new Bluebird((resolve, reject) => { + this.cursor.next((err, result: any) => { + if (err) return reject(err); + return resolve(result); + }); + }).then((document) => { + return new Bluebird((resolve, reject) => { + this.cursor.close((err) => { + if (err) return reject(err); + return resolve(document); + }); + }); + }).then((document) => { + if (!document) return Bluebird.resolve(null); + return this.model.handlers.documentReceived(this.conditions, document,(document, isNew?, isPartial?) => this.model.helpers.wrapDocument(document, isNew, isPartial)); + }).nodeify(callback); + } + /** * Returns a new cursor which behaves the same as this one did before any results were retrieved * @return {Cursor} The new cursor which starts at the beginning of the results From 7e0c6b38900845e45c506096b6d1dabfbcc9c529 Mon Sep 17 00:00:00 2001 From: Benjamin Pannell Date: Fri, 30 Oct 2015 15:52:48 +0200 Subject: [PATCH 3/5] ci: Have Travis publish npm versions --- .travis.yml | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/.travis.yml b/.travis.yml index 55b5b04..6af25c4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,33 +1,38 @@ language: node_js node_js: - - "0.10" - + - '0.10' services: - - mongodb - + - mongodb env: - - CI_SERVER=1 - + - CI_SERVER=1 addons: - code_climate: + code_climate: repo_token: 9c90177b42d39905ca635b1f6226580dab5799f87f172b66bab4e8df77b67a13 - before_install: - sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 - - echo 'deb http://repo.mongodb.org/apt/ubuntu precise/mongodb-org/3.0 multiverse' | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list - - echo 'deb http://repo.mongodb.org/apt/ubuntu precise/mongodb-org/3.1 multiverse' | sudo tee /etc/apt/sources.list.d/mongodb-org-3.1.list + - echo 'deb http://repo.mongodb.org/apt/ubuntu precise/mongodb-org/3.0 multiverse' + | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list + - echo 'deb http://repo.mongodb.org/apt/ubuntu precise/mongodb-org/3.1 multiverse' + | sudo tee /etc/apt/sources.list.d/mongodb-org-3.1.list - sudo apt-get update - sudo apt-get install -y mongodb-org mongodb-org-server mongodb-org-shell mongodb-org-tools - before_script: - - "until nc -z localhost 27017; do echo Waiting for MongoDB; sleep 1; done" - - "mongo --version" + - until nc -z localhost 27017; do echo Waiting for MongoDB; sleep 1; done + - mongo --version - gulp build - script: - gulp ci - after_script: - - gulp coverage - - coveralls < coverage/lcov.info - - codeclimate < coverage/lcov.info \ No newline at end of file + - gulp coverage + - coveralls < coverage/lcov.info + - codeclimate < coverage/lcov.info + +deploy: + skip_cleanup: true + provider: npm + email: admin@sierrasoftworks.com + api_key: + secure: A2tBD6QCdYd814GqbVNmVFzQjbAFF+4CK6JhOJEG3ovXwXuVbIlm+tSu6u+/zIS7ChTJ+RDKsY0/AlMrrhP4Qbm8pd0MsGNWMDPelklDXKHj8tw/s3FdXi8bU2Kn8IGAwMY729MMGdShvMbKx71Wt20jPQ/cMf2Bz25j4Q3WEMQ= + on: + branch: release + repo: SierraSoftworks/Iridium From 88b2d604e282f31e29454f679343953d9f74e941 Mon Sep 17 00:00:00 2001 From: Benjamin Pannell Date: Fri, 30 Oct 2015 15:53:33 +0200 Subject: [PATCH 4/5] Version 6.2.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 12bb21d..dc98f82 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "iridium", - "version": "6.1.1", + "version": "6.2.0", "author": "Benjamin Pannell ", "description": "A custom lightweight ORM for MongoDB designed for power-users", "license": "MIT", From be5e6981842f5e83e77229231e825fb2c0a0d88b Mon Sep 17 00:00:00 2001 From: Benjamin Pannell Date: Fri, 30 Oct 2015 15:53:40 +0200 Subject: [PATCH 5/5] Updated documentation --- CHANGELOG.md | 9 ++++++++- doc | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 01582ae..3219656 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,16 @@ +## [v6.2.0](https://github.com/sierrasoftworks/iridium/tree/v6.2.0) +- [88b2d60](https://github.com/sierrasoftworks/iridium/commit/88b2d60) Version 6.2.0 +- [7e0c6b3](https://github.com/sierrasoftworks/iridium/commit/7e0c6b3) (origin/master, origin/HEAD) ci: Have Travis publish npm versions +- [17edecd](https://github.com/sierrasoftworks/iridium/commit/17edecd) feat: Added one() method to cursor to read a single item from the database +- [fe1ab5f](https://github.com/sierrasoftworks/iridium/commit/fe1ab5f) feat: Added readFrom method to cursor +- [a914a64](https://github.com/sierrasoftworks/iridium/commit/a914a64) Updated Changelog + ## [v6.1.1](https://github.com/sierrasoftworks/iridium/tree/v6.1.1) - [5eb946f](https://github.com/sierrasoftworks/iridium/commit/5eb946f) Version 6.1.1 - [410ec6e](https://github.com/sierrasoftworks/iridium/commit/410ec6e) build: Rebuild all JS for coverage checking - [f8ebf0e](https://github.com/sierrasoftworks/iridium/commit/f8ebf0e) fix: Handle null config entry correctly -- [297fcdc](https://github.com/sierrasoftworks/iridium/commit/297fcdc) (origin/master, origin/HEAD) Updated CHANGELOG +- [297fcdc](https://github.com/sierrasoftworks/iridium/commit/297fcdc) Updated CHANGELOG - [30d132c](https://github.com/sierrasoftworks/iridium/commit/30d132c) Updated documentation ## [v6.1.0](https://github.com/sierrasoftworks/iridium/tree/v6.1.0) diff --git a/doc b/doc index 4e4ace3..e762cd5 160000 --- a/doc +++ b/doc @@ -1 +1 @@ -Subproject commit 4e4ace3faff0c11e7e469363b5eaeb61f6bfdb3e +Subproject commit e762cd53de59c0fd739ce5d2e1fc36b7dfbec518