├── .appveyor.yml ├── .babelrc ├── .gitignore ├── .travis.yml ├── CHANGELOG.md ├── LICENSE.txt ├── Makefile ├── README.md ├── api ├── README.md ├── classes │ ├── aggregation.md │ ├── basestore.md │ ├── binaryparser.md │ ├── binaryparserbuffer.md │ ├── clause.md │ ├── collection.md │ ├── connection.md │ ├── connectionhelper.md │ ├── cursor.md │ ├── document.md │ ├── eventemitter.md │ ├── mongoportable.md │ ├── objectid.md │ ├── options.md │ ├── selector.md │ ├── selectormatcher.md │ └── utils.md ├── interfaces │ └── iabstractstore.md └── out.json ├── bower.json ├── dist ├── mongo-portable.js ├── mongo-portable.js.map └── mongo-portable.min.js ├── docs ├── assets │ ├── css │ │ ├── main.css │ │ └── main.css.map │ ├── images │ │ ├── icons.png │ │ ├── icons@2x.png │ │ ├── widgets.png │ │ └── widgets@2x.png │ └── js │ │ ├── main.js │ │ └── search.js ├── classes │ ├── aggregation.html │ ├── basestore.html │ ├── binaryparser.html │ ├── binaryparserbuffer.html │ ├── clause.html │ ├── collection.html │ ├── connection.html │ ├── connectionhelper.html │ ├── cursor.html │ ├── document.html │ ├── eventemitter.html │ ├── mongoportable.html │ ├── objectid.html │ ├── options.html │ ├── selector.html │ ├── selectormatcher.html │ └── utils.html ├── globals.html ├── index.html ├── interfaces │ └── iabstractstore.html └── out.json ├── gulp └── tasks │ ├── build.js │ ├── docs.js │ ├── publish.js │ └── test.js ├── gulpfile.js ├── index.js ├── index.js.map ├── index.ts ├── jsdoc.conf.json ├── mkdocs.yml ├── package.json ├── src ├── aggregation │ ├── Aggregation.js │ ├── Aggregation.js.map │ ├── Aggregation.ts │ ├── index.js │ ├── index.js.map │ └── index.ts ├── binary │ ├── BinaryParser.js │ ├── BinaryParser.js.map │ ├── BinaryParser.ts │ ├── BinaryParserBuffer.js │ ├── BinaryParserBuffer.js.map │ ├── BinaryParserBuffer.ts │ ├── index.js │ ├── index.js.map │ └── index.ts ├── collection │ ├── Collection.js │ ├── Collection.js.map │ ├── Collection.ts │ ├── Cursor.js │ ├── Cursor.js.map │ ├── Cursor.ts │ ├── index.js │ ├── index.js.map │ └── index.ts ├── core │ ├── MongoPortable.js │ ├── MongoPortable.js.map │ ├── MongoPortable.ts │ ├── Options.js │ ├── Options.js.map │ ├── Options.ts │ ├── index.js │ ├── index.js.map │ └── index.ts ├── document │ ├── Document.js │ ├── Document.js.map │ ├── Document.ts │ ├── ObjectId.js │ ├── ObjectId.js.map │ ├── ObjectId.ts │ ├── index.js │ ├── index.js.map │ └── index.ts ├── emitter │ ├── EventEmitter.js │ ├── EventEmitter.js.map │ ├── EventEmitter.t │ ├── EventEmitter.ts │ ├── index.js │ ├── index.js.map │ └── index.ts ├── selector │ ├── Selector.js │ ├── Selector.js.map │ ├── Selector.ts │ ├── SelectorMatcher.js │ ├── SelectorMatcher.js.map │ ├── SelectorMatcher.ts │ ├── index.js │ ├── index.js.map │ └── index.ts ├── store │ ├── BaseStore.js │ ├── BaseStore.js.map │ ├── BaseStore.ts │ ├── IAbstractStore.js │ ├── IAbstractStore.js.map │ ├── IAbstractStore.ts │ ├── index.js │ ├── index.js.map │ └── index.ts └── utils │ ├── ConnectionHelper.js │ ├── ConnectionHelper.js.map │ ├── ConnectionHelper.ts │ ├── Utils.js │ ├── Utils.js.map │ ├── Utils.ts │ ├── index.js │ ├── index.js.map │ └── index.ts ├── test ├── helper │ ├── index.ts │ └── test.helper.ts ├── index.html ├── mocha.opts ├── specs │ ├── 1_ObjectId.js │ ├── 2_Selector.js │ ├── 3_Cursor.js │ ├── 4_Collection.js │ ├── 5_Aggregation.js │ ├── 6_MongoPortable.js │ └── 7_Coverage.js └── unit │ ├── aggregation │ └── Aggregation.spec.ts │ ├── binary │ ├── BinaryParser.spec.ts │ └── BinaryParserBuffer.spec.ts │ ├── collection │ ├── Collection.spec.ts │ └── Cursor.spec.ts │ ├── core │ ├── MongoPortable.spec.ts │ └── Options.spec.t_ │ ├── document │ ├── Document.spec.ts │ └── ObjectId.spec.ts │ ├── emitter │ └── EventEmitter.spec.ts │ ├── selector │ ├── Selector.spec.ts │ └── SelectorMatcher.spec.ts │ ├── store │ └── BaseStore.spec.ts │ └── utils │ ├── ConnectionHelper.spec.ts │ └── Utils.spec.ts ├── tsconfig.json └── yarn.lock /.appveyor.yml: -------------------------------------------------------------------------------- 1 | init: 2 | - git config --global core.autocrlf input 3 | 4 | environment: 5 | matrix: 6 | - nodejs_version: "6.9" 7 | 8 | install: 9 | - ps: Install-Product node $env:nodejs_version 10 | - npm install -g yarn && yarn 11 | 12 | build: off 13 | 14 | test_script: 15 | - node --version 16 | - npm --version 17 | - npm run build && npm run test 18 | 19 | version: "{build}" -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { "presets": ["es2015"] } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | lib 2 | 3 | npm-debug.log 4 | 5 | .coveralls.yml 6 | 7 | test/coverage 8 | test/results 9 | 10 | .nyc_output 11 | coverage 12 | node_modules 13 | 14 | logs/* 15 | 16 | .publish -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "4.4" 4 | - "6.9" 5 | sudo: false 6 | script: "npm run build && npm run test" 7 | after_success: npm run test.coveralls -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | # Unreleased (2017-11-02) 3 | 4 | 5 | 6 | 7 | # [2.0.0](https://github.com/EastolfiWebDev/MongoPortable/compare/2.0.0-rc1...2.0.0) (2017-11-02) 8 | 9 | 10 | ### Bug Fixes 11 | 12 | * Remove all documents if no selection passed. Closes [#6](https://github.com/EastolfiWebDev/MongoPortable/issues/6) ([43e979e](https://github.com/EastolfiWebDev/MongoPortable/commit/43e979e)) 13 | 14 | 15 | ### Features 16 | 17 | * Add a base store to be overriden ([0e7b780](https://github.com/EastolfiWebDev/MongoPortable/commit/0e7b780)) 18 | * Add multi connection support ([8cd9811](https://github.com/EastolfiWebDev/MongoPortable/commit/8cd9811)) 19 | 20 | 21 | 22 | 23 | # [2.0.0-rc1](https://github.com/EastolfiWebDev/MongoPortable/compare/1.4.0...2.0.0-rc1) (2017-10-24) 24 | 25 | 26 | ### Bug Fixes 27 | 28 | * Correct emit when no store ([fa45f12](https://github.com/EastolfiWebDev/MongoPortable/commit/fa45f12)) 29 | 30 | 31 | ### Code Refactoring 32 | 33 | * Drop all sync methods in Collection. ([65a7b88](https://github.com/EastolfiWebDev/MongoPortable/commit/65a7b88)) 34 | 35 | 36 | ### Features 37 | 38 | * Add multi connection support ([1982ca6](https://github.com/EastolfiWebDev/MongoPortable/commit/1982ca6)) 39 | 40 | 41 | ### BREAKING CHANGES 42 | 43 | * All methods now return a Promise. options.chain is now deprecated. 44 | 45 | 46 | 47 | 48 | # [1.4.0](https://github.com/EastolfiWebDev/MongoPortable/compare/1.3.2...1.4.0) (2017-08-18) 49 | 50 | 51 | ### Features 52 | 53 | * **core:** Add getInstance method ([febad5b](https://github.com/EastolfiWebDev/MongoPortable/commit/febad5b)) 54 | 55 | 56 | 57 | 58 | ## [1.3.2](https://github.com/EastolfiWebDev/MongoPortable/compare/1.3.1...1.3.2) (2017-01-26) 59 | 60 | 61 | ### Bug Fixes 62 | 63 | * Correct an error when emitting events from a collection ([d60ed21](https://github.com/EastolfiWebDev/MongoPortable/commit/d60ed21)) 64 | 65 | 66 | 67 | 68 | ## [1.3.1](https://github.com/EastolfiWebDev/MongoPortable/compare/1.3.0...1.3.1) (2017-01-25) 69 | 70 | 71 | ### Bug Fixes 72 | 73 | * Solve browser support ([d10406f](https://github.com/EastolfiWebDev/MongoPortable/commit/d10406f)) 74 | * Solve issue for unknown name "process" ([58fa3e5](https://github.com/EastolfiWebDev/MongoPortable/commit/58fa3e5)) 75 | 76 | 77 | 78 | 79 | # [1.3.0](https://github.com/EastolfiWebDev/MongoPortable/compare/v1.2.1...1.3.0) (2017-01-08) 80 | 81 | 82 | ### Bug Fixes 83 | 84 | * Solve a query problem when using stores ([1bca18d](https://github.com/EastolfiWebDev/MongoPortable/commit/1bca18d)) 85 | 86 | 87 | 88 | 89 | ## [1.2.1](https://github.com/EastolfiWebDev/MongoPortable/compare/v1.2.0...v1.2.1) (2016-10-19) 90 | 91 | 92 | 93 | 94 | # [1.2.0](https://github.com/EastolfiWebDev/MongoPortable/compare/v1.1.9...v1.2.0) (2016-10-19) 95 | 96 | 97 | ### Features 98 | 99 | * **aggregation:** Add aggregation stages: match, sort ([eba674a](https://github.com/EastolfiWebDev/MongoPortable/commit/eba674a)) 100 | * **aggregation:** Add aggregation stages: project ([d2f23eb](https://github.com/EastolfiWebDev/MongoPortable/commit/d2f23eb)) 101 | * **aggregation:** Add first aggregation functionallity ([03facba](https://github.com/EastolfiWebDev/MongoPortable/commit/03facba)) 102 | * **collection:** Add method Collection#bulkInsert ([a5641fc](https://github.com/EastolfiWebDev/MongoPortable/commit/a5641fc)) 103 | 104 | 105 | 106 | 107 | ## [1.1.9](https://github.com/EastolfiWebDev/MongoPortable/compare/v1.1.8...v1.1.9) (2016-10-19) 108 | 109 | 110 | 111 | 112 | ## [1.1.8](https://github.com/EastolfiWebDev/MongoPortable/compare/v1.1.7...v1.1.8) (2016-10-19) 113 | 114 | 115 | ### Features 116 | 117 | * **browser:** Add bower and browser support ([07768c5](https://github.com/EastolfiWebDev/MongoPortable/commit/07768c5)) 118 | 119 | 120 | 121 | 122 | ## [1.1.7](https://github.com/EastolfiWebDev/MongoPortable/compare/v1.1.6...v1.1.7) (2016-10-19) 123 | 124 | 125 | ### Bug Fixes 126 | 127 | * **cursor:** Fix when searching by _id ([766d454](https://github.com/EastolfiWebDev/MongoPortable/commit/766d454)) 128 | 129 | 130 | 131 | 132 | ## [1.1.6](https://github.com/EastolfiWebDev/MongoPortable/compare/v1.1.5...v1.1.6) (2016-10-19) 133 | 134 | 135 | ### Bug Fixes 136 | 137 | * **selector:** Correcte Selector operators ([b1f3399](https://github.com/EastolfiWebDev/MongoPortable/commit/b1f3399)) 138 | 139 | 140 | 141 | 142 | ## [1.1.5](https://github.com/EastolfiWebDev/MongoPortable/compare/v1.1.4...v1.1.5) (2016-10-19) 143 | 144 | 145 | 146 | 147 | ## [1.1.4](https://github.com/EastolfiWebDev/MongoPortable/compare/v1.1.3...v1.1.4) (2016-10-19) 148 | 149 | 150 | ### Features 151 | 152 | * **collection:** Add "destroy" and "delete" aliases for Collection#remove ([6fb15e0](https://github.com/EastolfiWebDev/MongoPortable/commit/6fb15e0)) 153 | 154 | 155 | 156 | 157 | ## [1.1.3](https://github.com/EastolfiWebDev/MongoPortable/compare/v1.1.2...v1.1.3) (2016-10-19) 158 | 159 | 160 | 161 | 162 | ## [1.1.2](https://github.com/EastolfiWebDev/MongoPortable/compare/v1.1.1...v1.1.2) (2016-10-19) 163 | 164 | 165 | 166 | 167 | ## [1.1.1](https://github.com/EastolfiWebDev/MongoPortable/compare/v1.1.0...v1.1.1) (2016-10-19) 168 | 169 | 170 | 171 | 172 | # [1.1.0](https://github.com/EastolfiWebDev/MongoPortable/compare/v1.0.0...v1.1.0) (2016-10-19) 173 | 174 | 175 | 176 | 177 | # [1.0.0](https://github.com/EastolfiWebDev/MongoPortable/compare/v1.0.0-0...v1.0.0) (2016-10-19) 178 | 179 | 180 | 181 | 182 | # [1.0.0-0](https://github.com/EastolfiWebDev/MongoPortable/compare/v0.0.1...v1.0.0-0) (2016-10-19) 183 | 184 | 185 | 186 | 187 | ## [0.0.1](https://github.com/EastolfiWebDev/MongoPortable/compare/9b42db2...v0.0.1) (2016-10-19) 188 | 189 | 190 | ### Features 191 | 192 | * **module:** Create the module ([9b42db2](https://github.com/EastolfiWebDev/MongoPortable/commit/9b42db2)) 193 | 194 | 195 | 196 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Eduardo Astolfi 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | ==== 24 | 25 | All files located in the node_modules and external directories are 26 | externally maintained libraries used by this software which have their 27 | own licenses; we recommend you read them, as their terms may differ from 28 | the terms above. -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | ## Variables ## 2 | 3 | # Global Packages # 4 | grunt = ./node_modules/.bin/grunt 5 | mocha = ./node_modules/.bin/mocha 6 | coveralls = ./node_modules/.bin/coveralls 7 | jscoverage = ./node_modules/.bin/jscoverage 8 | 9 | # Building # 10 | build_app = $(grunt) build_app 11 | 12 | compress_bundle = $(grunt) bundle 13 | 14 | build_web_full = $(grunt) build_doc 15 | 16 | build_api_full = $(grunt) build_html 17 | 18 | # Testing # 19 | run_test = $(grunt) test 20 | 21 | coveralls = $(grunt) coveralls_dist 22 | 23 | # Publishing # 24 | npm_publish = npm publish 25 | 26 | # Cleaning # 27 | clean_test = rm -rf test/coverage && rm -rf test/results && rm -rf lib-cov 28 | 29 | ## Actions ## 30 | 31 | # Running Tests # 32 | 33 | test: bundle 34 | $(run_test) 35 | 36 | do_coverage: test 37 | $(clean_test) 38 | mkdir test/coverage && mkdir test/results 39 | $(jscoverage) --no-highlight lib lib-cov 40 | mv lib lib-orig 41 | mv lib-cov lib 42 | $(mocha) test -R html-cov > test/results/coverage.html 43 | $(mocha) test -R mocha-lcov-reporter > test/coverage/coverage-dist.lcov 44 | rm -rf lib 45 | mv lib-orig lib 46 | 47 | coverage: do_coverage 48 | $(coveralls) 49 | 50 | # Building Application # 51 | 52 | build: 53 | $(build_app) 54 | 55 | bundle: build 56 | $(compress_bundle) 57 | 58 | build_all: build bundle build_full_doc test coverage 59 | 60 | # Building Documentation # 61 | 62 | build_web_doc: build 63 | $(build_web_full) 64 | 65 | build_api_doc: build 66 | $(build_api_full) 67 | 68 | build_full_doc: build 69 | $(build_web_full) 70 | $(build_api_full) 71 | 72 | ## Publishg ## 73 | 74 | # NPM # 75 | 76 | npm_major: test 77 | npm version major --no-git-tag-version 78 | git commit -m "VERSION: New major version released" 79 | 80 | npm_minor: test 81 | npm version minor --no-git-tag-version 82 | git commit -m "VERSION: New minor version released" 83 | 84 | npm_patch: test 85 | npm version patch --no-git-tag-version 86 | git commit -m "VERSION: New patch released" 87 | 88 | # Bower # 89 | 90 | bower_major: test 91 | bower version major -m "VERSION: New major version released (v%s)" 92 | git push -u origin --follow-tags 93 | 94 | bower_minor: test 95 | bower version minor -m "VERSION: New minor version released (v%s)" 96 | git push -u origin --follow-tags 97 | 98 | bower_patch: test 99 | bower version patch -m "VERSION: New patch released (v%s)" 100 | git push -u origin --follow-tags 101 | 102 | # NPM & Bower # 103 | 104 | publish_major: 105 | make npm_major 106 | make bower_major 107 | npm publish 108 | 109 | publish_minor: 110 | make npm_minor 111 | make bower_minor 112 | npm publish 113 | 114 | publish_patch: 115 | make npm_patch 116 | make bower_patch 117 | npm publish 118 | 119 | .PHONY: build_all, publish_major, publish_minor, publish_patch -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MongoPortable 2 | Solution for a MongoDB-like portable database. 3 | 4 | [![Package Version][npm-image]][npm-url] 5 | [![NodeJS Version][node-image]][node-url] 6 | 7 | [![Linux Build][travis-image]][travis-url] 8 | [![Windows Build][appveyor-image]][appveyor-url] 9 | [![Codeship Build][codeship-image]][codeship-url] 10 | 11 | [![Test Coverage][coveralls-image]][coveralls-url] 12 | [![Downloads][downloads-image]][npm-url] 13 | [![Documentation Status][docs-image]][docs-url] 14 | 15 | It handles the collections and documents in memory, and allow the use of stores for persistence. 16 | 17 | # Installation 18 | ```shell 19 | npm install --save mongo-portable 20 | ``` 21 | # Usage 22 | ```javascript 23 | // Declaring the module dependency 24 | var MongoPortable = require("mongo-portable").MongoPortable; 25 | 26 | // Instantiates a new ddbb object by passing a ddbb name 27 | var db = new MongoPortable("TEST"); 28 | 29 | // Creates a new collection named "users" 30 | // (if it's already created, it will just return it instead) 31 | var users = db.collection("users"); 32 | 33 | // Inserts a new document into the collection 34 | var document = users.insert({ name: "John", lastName: "Abruzzi" }); 35 | console.log(document); // -> { name: "John", lastName: "Abruzzi" } 36 | 37 | // Creates a cursor with the query information, ready to be fetched 38 | var cursor = users.find({ name: "John" }); 39 | 40 | // Iterates over the cursor, obtaining each document that matchs the query 41 | cursor.forEach(function(doc) { 42 | console.log(doc); // -> { name: "John", lastName: "Abruzzi" } 43 | }); 44 | ``` 45 | 46 | # Modules 47 | The modules visibles for an application are [MongoPortable](#MongoPortable), [Collection](#Collection) and [Cursor](#Cursor). 48 | 49 | ## MongoPortable 50 | Handles the database, collections and connections. 51 | 52 | Read the full API documentation [here][API-MongoPortable] 53 | 54 | ## Collection 55 | Handles the list of documents by using cursors. 56 | 57 | Read the full API documentation [here][API-Collection] 58 | 59 | ## Cursor 60 | Fetchs and access the documents to return them to the client. 61 | 62 | Read the full API documentation [here][API-Cursor] 63 | 64 | ---------- 65 | 66 | # Stores 67 | ## File System Store 68 | It is located in a separated module, so install it by: 69 | ```shell 70 | npm install --save file-system-store 71 | ``` 72 | And then use it in your application by adding it in your MongoPortable instance: 73 | ```javascript 74 | var FileSystemStore = require("file-system-store"); 75 | db.addStore(FileSystemStore); 76 | ``` 77 | or as a middleware: 78 | ```javascript 79 | var FileSystemStore = require("file-system-store"); 80 | db.use("store", FileSystemStore); 81 | ``` 82 | 83 | View the package [here][Module-FileSystemStore] and read the full API documentation [here][API-FileSystemStore] 84 | 85 | ---------- 86 | 87 | ## TO-DO List 88 | ### Database Operations 89 | - [ ] DDBB 90 | * [X] .use() (Middleware) 91 | * [X] .addStore() 92 | * [X] .dropDatabase() 93 | * [ ] Connections 94 | - [ ] Collections 95 | * [ ] .collectionsInfo() 96 | * [X] .collections() 97 | * [X] .collectionNames() 98 | * [X] .collection() 99 | * [X] .dropCollection() 100 | * [X] .renameCollection() 101 | * [X] .dropCollection() 102 | * [X] .dropCollection() 103 | * [X] .dropCollection() 104 | - [ ] Indexes 105 | * [ ] .createIndex() 106 | * [ ] .ensureIndex() 107 | * [ ] .dropIndex() 108 | * [ ] .reIndex() 109 | * [ ] .indexInformation() 110 | - [ ] [db.runCommand()][Mongo-db-command] 111 | * [ ] User Commands 112 | * [ ] Database Operations 113 | * [ ] Internal Commands 114 | * [ ] Testing Commands 115 | * [ ] Auditing Commands 116 | 117 | Read the full API documentation [here][API-MongoPortable] 118 | 119 | ---------- 120 | 121 | ## Collection 122 | - [X] Creating 123 | * [X] .insert() 124 | - [X] Reading 125 | * [X] .find() 126 | * [X] .findOne() 127 | - [X] Updating 128 | * [X] .update() 129 | - [X] Deleting 130 | * [X] .remove() 131 | 132 | Read the full API documentation [here][API-Collection] 133 | 134 | ---------- 135 | 136 | ## Cursor 137 | - [X] Fetching 138 | * [X] .rewind() 139 | * [X] .forEach() 140 | * [X] .map() 141 | * [X] .hasNext() 142 | * [X] .next() 143 | * [X] .fetchAll() 144 | * [X] .fetchOne() 145 | * [X] .count() 146 | * [X] .sort() 147 | * [X] .skip() 148 | * [X] .limit() 149 | - [ ] Managing 150 | * [ ] .batchSize() 151 | * [ ] .close() 152 | * [ ] .comment() 153 | * [ ] .explain() 154 | * [ ] .hint() 155 | * [ ] .itcount() 156 | * [ ] .maxScan() 157 | * [ ] .maxTimeMS() 158 | * [ ] .max() 159 | * [ ] .min() 160 | * [ ] .noCursorTimeout() 161 | * [ ] .objsLeftInBatch() 162 | * [ ] .pretty() 163 | * [ ] .readConcern() 164 | * [ ] .readPref() 165 | * [ ] .returnKey() 166 | * [ ] .showRecordId() 167 | * [ ] .size() 168 | * [ ] .snapshot() 169 | * [ ] .tailable() 170 | * [ ] .toArray() 171 | 172 | Read the full API documentation [here][API-Cursor] 173 | 174 | ---------- 175 | 176 | # License 177 | 178 | MIT 179 | 180 | [mongo-db-command]: https://docs.mongodb.com/manual/reference/command/ 181 | 182 | [API-MongoPortable]: https://github.com/EastolfiWebDev/MongoPortable/blob/master/api/MongoPortable.md 183 | [API-Collection]: https://github.com/EastolfiWebDev/MongoPortable/blob/master/api/Collection.md 184 | [API-Cursor]: https://github.com/EastolfiWebDev/MongoPortable/blob/master/api/Cursor.md 185 | 186 | [Module-FileSystemStore]: https://github.com/EastolfiWebDev/FileSystemStore 187 | [API-FileSystemStore]: https://github.com/EastolfiWebDev/FileSystemStore/blob/master/api/FileSystemStore.md 188 | 189 | [npm-image]: https://img.shields.io/npm/v/mongo-portable.svg?label=Package%20Version 190 | [npm-url]: https://www.npmjs.com/package/mongo-portable 191 | [node-image]: https://img.shields.io/badge/node-v4.4.0-blue.svg?label=Node%20Version 192 | [node-url]: https://nodejs.org/en/ 193 | [travis-image]: https://img.shields.io/travis/EastolfiWebDev/MongoPortable.svg?label=linux 194 | [travis-url]: https://travis-ci.org/EastolfiWebDev/MongoPortable 195 | [appveyor-image]: https://img.shields.io/appveyor/ci/eastolfi/MongoPortable/master.svg?label=windows 196 | [appveyor-url]: https://ci.appveyor.com/project/eastolfi/mongoportable 197 | [codeship-image]: https://codeship.com/projects/d57e8820-5e10-0134-8b6d-42ae3f63aed8/status?branch=master 198 | [codeship-url]: https://codeship.com/projects/174143 199 | 200 | [coveralls-image]: https://coveralls.io/repos/github/EastolfiWebDev/MongoPortable/badge.svg?branch=master 201 | [coveralls-url]: https://coveralls.io/github/EastolfiWebDev/MongoPortable?branch=master 202 | [downloads-image]: https://img.shields.io/npm/dt/mongo-portable.svg 203 | [docs-image]: https://readthedocs.org/projects/mongoportable/badge/?version=latest 204 | [docs-url]: http://mongoportable.readthedocs.io/en/latest/?badge=latest 205 | -------------------------------------------------------------------------------- /api/classes/aggregation.md: -------------------------------------------------------------------------------- 1 | [Mongo Portable](../README.md) > [Aggregation](../classes/aggregation.md) 2 | 3 | 4 | 5 | # Class: Aggregation 6 | 7 | ## Index 8 | 9 | ### Constructors 10 | 11 | * [constructor](aggregation.md#constructor) 12 | 13 | 14 | ### Properties 15 | 16 | * [logger](aggregation.md#logger) 17 | * [pipeline](aggregation.md#pipeline) 18 | 19 | 20 | ### Methods 21 | 22 | * [aggregate](aggregation.md#aggregate) 23 | * [validStage](aggregation.md#validstage) 24 | 25 | 26 | 27 | --- 28 | ## Constructors 29 | 30 | 31 | 32 | ### ⊕ **new Aggregation**(pipeline: *`any`*): [Aggregation](aggregation.md) 33 | 34 | 35 | *Defined in [aggregation/Aggregation.ts:201](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/aggregation/Aggregation.ts#L201)* 36 | 37 | 38 | 39 | **Parameters:** 40 | 41 | | Param | Type | Description | 42 | | ------ | ------ | ------ | 43 | | pipeline | `any` | - | 44 | 45 | 46 | 47 | 48 | 49 | **Returns:** [Aggregation](aggregation.md) 50 | 51 | --- 52 | 53 | 54 | ## Properties 55 | 56 | 57 | ### «Protected» logger 58 | 59 | **● logger**: *`JSWLogger`* 60 | 61 | *Defined in [aggregation/Aggregation.ts:199](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/aggregation/Aggregation.ts#L199)* 62 | 63 | 64 | 65 | 66 | 67 | ___ 68 | 69 | 70 | 71 | ### pipeline 72 | 73 | **● pipeline**: *`any`* 74 | 75 | *Defined in [aggregation/Aggregation.ts:201](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/aggregation/Aggregation.ts#L201)* 76 | 77 | 78 | 79 | 80 | 81 | ___ 82 | 83 | 84 | ## Methods 85 | 86 | 87 | ### aggregate 88 | 89 | ► **aggregate**(collection: *`any`*): `any` 90 | 91 | 92 | 93 | *Defined in [aggregation/Aggregation.ts:209](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/aggregation/Aggregation.ts#L209)* 94 | 95 | 96 | 97 | **Parameters:** 98 | 99 | | Param | Type | Description | 100 | | ------ | ------ | ------ | 101 | | collection | `any` | - | 102 | 103 | 104 | 105 | 106 | 107 | **Returns:** `any` 108 | 109 | 110 | 111 | 112 | 113 | ___ 114 | 115 | 116 | 117 | ### validStage 118 | 119 | ► **validStage**(stage: *`any`*): `string`⎮`true`⎮`false` 120 | 121 | 122 | 123 | *Defined in [aggregation/Aggregation.ts:240](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/aggregation/Aggregation.ts#L240)* 124 | 125 | 126 | 127 | **Parameters:** 128 | 129 | | Param | Type | Description | 130 | | ------ | ------ | ------ | 131 | | stage | `any` | - | 132 | 133 | 134 | 135 | 136 | 137 | **Returns:** `string`⎮`true`⎮`false` 138 | 139 | 140 | 141 | 142 | 143 | ___ 144 | 145 | 146 | -------------------------------------------------------------------------------- /api/classes/basestore.md: -------------------------------------------------------------------------------- 1 | [Mongo Portable](../README.md) > [BaseStore](../classes/basestore.md) 2 | 3 | 4 | 5 | # Class: BaseStore 6 | 7 | ## Implements 8 | 9 | * [IAbstractStore](../interfaces/iabstractstore.md) 10 | 11 | ## Index 12 | 13 | ### Methods 14 | 15 | * [all](basestore.md#all) 16 | * [backup](basestore.md#backup) 17 | * [backups](basestore.md#backups) 18 | * [createCollection](basestore.md#createcollection) 19 | * [ensureIndex](basestore.md#ensureindex) 20 | * [find](basestore.md#find) 21 | * [findOne](basestore.md#findone) 22 | * [insert](basestore.md#insert) 23 | * [remove](basestore.md#remove) 24 | * [removeBackup](basestore.md#removebackup) 25 | * [restore](basestore.md#restore) 26 | * [save](basestore.md#save) 27 | * [update](basestore.md#update) 28 | 29 | 30 | 31 | --- 32 | ## Methods 33 | 34 | 35 | ### all 36 | 37 | ► **all**(event: *`any`*): `any`⎮`Promise`.<`any`> 38 | 39 | 40 | 41 | *Implementation of [IAbstractStore](../interfaces/iabstractstore.md).[all](../interfaces/iabstractstore.md#all)* 42 | 43 | *Defined in [store/BaseStore.ts:18](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/store/BaseStore.ts#L18)* 44 | 45 | 46 | 47 | **Parameters:** 48 | 49 | | Param | Type | Description | 50 | | ------ | ------ | ------ | 51 | | event | `any` | - | 52 | 53 | 54 | 55 | 56 | 57 | **Returns:** `any`⎮`Promise`.<`any`> 58 | 59 | 60 | 61 | 62 | 63 | ___ 64 | 65 | 66 | 67 | ### backup 68 | 69 | ► **backup**(event: *`any`*): `any`⎮`Promise`.<`any`> 70 | 71 | 72 | 73 | *Implementation of [IAbstractStore](../interfaces/iabstractstore.md).[backup](../interfaces/iabstractstore.md#backup)* 74 | 75 | *Defined in [store/BaseStore.ts:42](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/store/BaseStore.ts#L42)* 76 | 77 | 78 | 79 | **Parameters:** 80 | 81 | | Param | Type | Description | 82 | | ------ | ------ | ------ | 83 | | event | `any` | - | 84 | 85 | 86 | 87 | 88 | 89 | **Returns:** `any`⎮`Promise`.<`any`> 90 | 91 | 92 | 93 | 94 | 95 | ___ 96 | 97 | 98 | 99 | ### backups 100 | 101 | ► **backups**(event: *`any`*): `any`⎮`Promise`.<`any`> 102 | 103 | 104 | 105 | *Implementation of [IAbstractStore](../interfaces/iabstractstore.md).[backups](../interfaces/iabstractstore.md#backups)* 106 | 107 | *Defined in [store/BaseStore.ts:46](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/store/BaseStore.ts#L46)* 108 | 109 | 110 | 111 | **Parameters:** 112 | 113 | | Param | Type | Description | 114 | | ------ | ------ | ------ | 115 | | event | `any` | - | 116 | 117 | 118 | 119 | 120 | 121 | **Returns:** `any`⎮`Promise`.<`any`> 122 | 123 | 124 | 125 | 126 | 127 | ___ 128 | 129 | 130 | 131 | ### createCollection 132 | 133 | ► **createCollection**(event: *`any`*): `boolean`⎮`Promise`.<`boolean`> 134 | 135 | 136 | 137 | *Implementation of [IAbstractStore](../interfaces/iabstractstore.md).[createCollection](../interfaces/iabstractstore.md#createcollection)* 138 | 139 | *Defined in [store/BaseStore.ts:6](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/store/BaseStore.ts#L6)* 140 | 141 | 142 | 143 | **Parameters:** 144 | 145 | | Param | Type | Description | 146 | | ------ | ------ | ------ | 147 | | event | `any` | - | 148 | 149 | 150 | 151 | 152 | 153 | **Returns:** `boolean`⎮`Promise`.<`boolean`> 154 | 155 | 156 | 157 | 158 | 159 | ___ 160 | 161 | 162 | 163 | ### ensureIndex 164 | 165 | ► **ensureIndex**(event: *`any`*): `any`⎮`Promise`.<`any`> 166 | 167 | 168 | 169 | *Implementation of [IAbstractStore](../interfaces/iabstractstore.md).[ensureIndex](../interfaces/iabstractstore.md#ensureindex)* 170 | 171 | *Defined in [store/BaseStore.ts:38](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/store/BaseStore.ts#L38)* 172 | 173 | 174 | 175 | **Parameters:** 176 | 177 | | Param | Type | Description | 178 | | ------ | ------ | ------ | 179 | | event | `any` | - | 180 | 181 | 182 | 183 | 184 | 185 | **Returns:** `any`⎮`Promise`.<`any`> 186 | 187 | 188 | 189 | 190 | 191 | ___ 192 | 193 | 194 | 195 | ### find 196 | 197 | ► **find**(event: *`any`*): `any`⎮`Promise`.<`any`> 198 | 199 | 200 | 201 | *Implementation of [IAbstractStore](../interfaces/iabstractstore.md).[find](../interfaces/iabstractstore.md#find)* 202 | 203 | *Defined in [store/BaseStore.ts:22](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/store/BaseStore.ts#L22)* 204 | 205 | 206 | 207 | **Parameters:** 208 | 209 | | Param | Type | Description | 210 | | ------ | ------ | ------ | 211 | | event | `any` | - | 212 | 213 | 214 | 215 | 216 | 217 | **Returns:** `any`⎮`Promise`.<`any`> 218 | 219 | 220 | 221 | 222 | 223 | ___ 224 | 225 | 226 | 227 | ### findOne 228 | 229 | ► **findOne**(event: *`any`*): `any`⎮`Promise`.<`any`> 230 | 231 | 232 | 233 | *Implementation of [IAbstractStore](../interfaces/iabstractstore.md).[findOne](../interfaces/iabstractstore.md#findone)* 234 | 235 | *Defined in [store/BaseStore.ts:26](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/store/BaseStore.ts#L26)* 236 | 237 | 238 | 239 | **Parameters:** 240 | 241 | | Param | Type | Description | 242 | | ------ | ------ | ------ | 243 | | event | `any` | - | 244 | 245 | 246 | 247 | 248 | 249 | **Returns:** `any`⎮`Promise`.<`any`> 250 | 251 | 252 | 253 | 254 | 255 | ___ 256 | 257 | 258 | 259 | ### insert 260 | 261 | ► **insert**(event: *`any`*): `boolean`⎮`Promise`.<`boolean`> 262 | 263 | 264 | 265 | *Implementation of [IAbstractStore](../interfaces/iabstractstore.md).[insert](../interfaces/iabstractstore.md#insert)* 266 | 267 | *Defined in [store/BaseStore.ts:10](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/store/BaseStore.ts#L10)* 268 | 269 | 270 | 271 | **Parameters:** 272 | 273 | | Param | Type | Description | 274 | | ------ | ------ | ------ | 275 | | event | `any` | - | 276 | 277 | 278 | 279 | 280 | 281 | **Returns:** `boolean`⎮`Promise`.<`boolean`> 282 | 283 | 284 | 285 | 286 | 287 | ___ 288 | 289 | 290 | 291 | ### remove 292 | 293 | ► **remove**(event: *`any`*): `boolean`⎮`Promise`.<`boolean`> 294 | 295 | 296 | 297 | *Implementation of [IAbstractStore](../interfaces/iabstractstore.md).[remove](../interfaces/iabstractstore.md#remove)* 298 | 299 | *Defined in [store/BaseStore.ts:34](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/store/BaseStore.ts#L34)* 300 | 301 | 302 | 303 | **Parameters:** 304 | 305 | | Param | Type | Description | 306 | | ------ | ------ | ------ | 307 | | event | `any` | - | 308 | 309 | 310 | 311 | 312 | 313 | **Returns:** `boolean`⎮`Promise`.<`boolean`> 314 | 315 | 316 | 317 | 318 | 319 | ___ 320 | 321 | 322 | 323 | ### removeBackup 324 | 325 | ► **removeBackup**(event: *`any`*): `any`⎮`Promise`.<`any`> 326 | 327 | 328 | 329 | *Implementation of [IAbstractStore](../interfaces/iabstractstore.md).[removeBackup](../interfaces/iabstractstore.md#removebackup)* 330 | 331 | *Defined in [store/BaseStore.ts:50](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/store/BaseStore.ts#L50)* 332 | 333 | 334 | 335 | **Parameters:** 336 | 337 | | Param | Type | Description | 338 | | ------ | ------ | ------ | 339 | | event | `any` | - | 340 | 341 | 342 | 343 | 344 | 345 | **Returns:** `any`⎮`Promise`.<`any`> 346 | 347 | 348 | 349 | 350 | 351 | ___ 352 | 353 | 354 | 355 | ### restore 356 | 357 | ► **restore**(event: *`any`*): `any`⎮`Promise`.<`any`> 358 | 359 | 360 | 361 | *Implementation of [IAbstractStore](../interfaces/iabstractstore.md).[restore](../interfaces/iabstractstore.md#restore)* 362 | 363 | *Defined in [store/BaseStore.ts:54](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/store/BaseStore.ts#L54)* 364 | 365 | 366 | 367 | **Parameters:** 368 | 369 | | Param | Type | Description | 370 | | ------ | ------ | ------ | 371 | | event | `any` | - | 372 | 373 | 374 | 375 | 376 | 377 | **Returns:** `any`⎮`Promise`.<`any`> 378 | 379 | 380 | 381 | 382 | 383 | ___ 384 | 385 | 386 | 387 | ### save 388 | 389 | ► **save**(event: *`any`*): `any`⎮`Promise`.<`any`> 390 | 391 | 392 | 393 | *Implementation of [IAbstractStore](../interfaces/iabstractstore.md).[save](../interfaces/iabstractstore.md#save)* 394 | 395 | *Defined in [store/BaseStore.ts:14](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/store/BaseStore.ts#L14)* 396 | 397 | 398 | 399 | **Parameters:** 400 | 401 | | Param | Type | Description | 402 | | ------ | ------ | ------ | 403 | | event | `any` | - | 404 | 405 | 406 | 407 | 408 | 409 | **Returns:** `any`⎮`Promise`.<`any`> 410 | 411 | 412 | 413 | 414 | 415 | ___ 416 | 417 | 418 | 419 | ### update 420 | 421 | ► **update**(event: *`any`*): `boolean`⎮`Promise`.<`boolean`> 422 | 423 | 424 | 425 | *Implementation of [IAbstractStore](../interfaces/iabstractstore.md).[update](../interfaces/iabstractstore.md#update)* 426 | 427 | *Defined in [store/BaseStore.ts:30](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/store/BaseStore.ts#L30)* 428 | 429 | 430 | 431 | **Parameters:** 432 | 433 | | Param | Type | Description | 434 | | ------ | ------ | ------ | 435 | | event | `any` | - | 436 | 437 | 438 | 439 | 440 | 441 | **Returns:** `boolean`⎮`Promise`.<`boolean`> 442 | 443 | 444 | 445 | 446 | 447 | ___ 448 | 449 | 450 | -------------------------------------------------------------------------------- /api/classes/binaryparserbuffer.md: -------------------------------------------------------------------------------- 1 | [Mongo Portable](../README.md) > [BinaryParserBuffer](../classes/binaryparserbuffer.md) 2 | 3 | 4 | 5 | # Class: BinaryParserBuffer 6 | 7 | 8 | BinaryParserBuffer 9 | *__module__*: BinaryParserBuffer 10 | 11 | *__since__*: 0.0.1 12 | 13 | *__author__*: Eduardo Astolfi [eastolfi91@gmail.com](mailto:eastolfi91@gmail.com) 14 | 15 | *__copyright__*: 2016 Eduardo Astolfi [eastolfi91@gmail.com](mailto:eastolfi91@gmail.com) 16 | 17 | *__license__*: MIT Licensed 18 | 19 | *__classdesc__*: BinaryParserBuffer - based on ([Binary Parser](http://jsfromhell.com/classes/binary-parser)) by Jonas Raoni Soares Silva 20 | 21 | 22 | ## Index 23 | 24 | ### Constructors 25 | 26 | * [constructor](binaryparserbuffer.md#constructor) 27 | 28 | 29 | ### Properties 30 | 31 | * [bigEndian](binaryparserbuffer.md#bigendian) 32 | * [buffer](binaryparserbuffer.md#buffer) 33 | * [logger](binaryparserbuffer.md#logger) 34 | 35 | 36 | ### Methods 37 | 38 | * [checkBuffer](binaryparserbuffer.md#checkbuffer) 39 | * [hasNeededBits](binaryparserbuffer.md#hasneededbits) 40 | * [readBits](binaryparserbuffer.md#readbits) 41 | * [setBuffer](binaryparserbuffer.md#setbuffer) 42 | 43 | 44 | 45 | --- 46 | ## Constructors 47 | 48 | 49 | 50 | ### ⊕ **new BinaryParserBuffer**(bigEndian: *`any`*, buffer: *`string`⎮`number`*): [BinaryParserBuffer](binaryparserbuffer.md) 51 | 52 | 53 | *Defined in [binary/BinaryParserBuffer.ts:19](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/binary/BinaryParserBuffer.ts#L19)* 54 | 55 | 56 | 57 | **Parameters:** 58 | 59 | | Param | Type | Description | 60 | | ------ | ------ | ------ | 61 | | bigEndian | `any` | - | 62 | | buffer | `string`⎮`number` | - | 63 | 64 | 65 | 66 | 67 | 68 | **Returns:** [BinaryParserBuffer](binaryparserbuffer.md) 69 | 70 | --- 71 | 72 | 73 | ## Properties 74 | 75 | 76 | ### bigEndian 77 | 78 | **● bigEndian**: *`number`* 79 | 80 | *Defined in [binary/BinaryParserBuffer.ts:18](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/binary/BinaryParserBuffer.ts#L18)* 81 | 82 | 83 | 84 | 85 | 86 | ___ 87 | 88 | 89 | 90 | ### buffer 91 | 92 | **● buffer**: *`Array`.<`any`>* = [] 93 | 94 | *Defined in [binary/BinaryParserBuffer.ts:19](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/binary/BinaryParserBuffer.ts#L19)* 95 | 96 | 97 | 98 | 99 | 100 | ___ 101 | 102 | 103 | 104 | ### «Protected» logger 105 | 106 | **● logger**: *`JSWLogger`* 107 | 108 | *Defined in [binary/BinaryParserBuffer.ts:16](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/binary/BinaryParserBuffer.ts#L16)* 109 | 110 | 111 | 112 | 113 | 114 | ___ 115 | 116 | 117 | ## Methods 118 | 119 | 120 | ### checkBuffer 121 | 122 | ► **checkBuffer**(neededBits: *`any`*): `void` 123 | 124 | 125 | 126 | *Defined in [binary/BinaryParserBuffer.ts:50](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/binary/BinaryParserBuffer.ts#L50)* 127 | 128 | 129 | 130 | **Parameters:** 131 | 132 | | Param | Type | Description | 133 | | ------ | ------ | ------ | 134 | | neededBits | `any` | - | 135 | 136 | 137 | 138 | 139 | 140 | **Returns:** `void` 141 | 142 | 143 | 144 | 145 | 146 | ___ 147 | 148 | 149 | 150 | ### hasNeededBits 151 | 152 | ► **hasNeededBits**(neededBits: *`any`*): `boolean` 153 | 154 | 155 | 156 | *Defined in [binary/BinaryParserBuffer.ts:46](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/binary/BinaryParserBuffer.ts#L46)* 157 | 158 | 159 | 160 | **Parameters:** 161 | 162 | | Param | Type | Description | 163 | | ------ | ------ | ------ | 164 | | neededBits | `any` | - | 165 | 166 | 167 | 168 | 169 | 170 | **Returns:** `boolean` 171 | 172 | 173 | 174 | 175 | 176 | ___ 177 | 178 | 179 | 180 | ### readBits 181 | 182 | ► **readBits**(start: *`number`*, length: *`number`*): `number` 183 | 184 | 185 | 186 | *Defined in [binary/BinaryParserBuffer.ts:56](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/binary/BinaryParserBuffer.ts#L56)* 187 | 188 | 189 | 190 | **Parameters:** 191 | 192 | | Param | Type | Description | 193 | | ------ | ------ | ------ | 194 | | start | `number` | - | 195 | | length | `number` | - | 196 | 197 | 198 | 199 | 200 | 201 | **Returns:** `number` 202 | 203 | 204 | 205 | 206 | 207 | ___ 208 | 209 | 210 | 211 | ### setBuffer 212 | 213 | ► **setBuffer**(data: *`string`*): `void` 214 | 215 | 216 | 217 | *Defined in [binary/BinaryParserBuffer.ts:33](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/binary/BinaryParserBuffer.ts#L33)* 218 | 219 | 220 | 221 | **Parameters:** 222 | 223 | | Param | Type | Description | 224 | | ------ | ------ | ------ | 225 | | data | `string` | - | 226 | 227 | 228 | 229 | 230 | 231 | **Returns:** `void` 232 | 233 | 234 | 235 | 236 | 237 | ___ 238 | 239 | 240 | -------------------------------------------------------------------------------- /api/classes/clause.md: -------------------------------------------------------------------------------- 1 | [Mongo Portable](../README.md) > [Clause](../classes/clause.md) 2 | 3 | 4 | 5 | # Class: Clause 6 | 7 | ## Index 8 | 9 | ### Properties 10 | 11 | * [key](clause.md#key) 12 | * [kind](clause.md#kind) 13 | * [type](clause.md#type) 14 | * [value](clause.md#value) 15 | 16 | 17 | 18 | --- 19 | ## Properties 20 | 21 | 22 | ### key 23 | 24 | **● key**: *`string`* 25 | 26 | *Defined in [selector/Selector.ts:10](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/selector/Selector.ts#L10)* 27 | 28 | 29 | 30 | 31 | 32 | ___ 33 | 34 | 35 | 36 | ### kind 37 | 38 | **● kind**: *`string`* 39 | 40 | *Defined in [selector/Selector.ts:11](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/selector/Selector.ts#L11)* 41 | 42 | 43 | 44 | 45 | 46 | ___ 47 | 48 | 49 | 50 | ### type 51 | 52 | **● type**: *`string`* 53 | 54 | *Defined in [selector/Selector.ts:12](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/selector/Selector.ts#L12)* 55 | 56 | 57 | 58 | 59 | 60 | ___ 61 | 62 | 63 | 64 | ### value 65 | 66 | **● value**: *`any`* 67 | 68 | *Defined in [selector/Selector.ts:13](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/selector/Selector.ts#L13)* 69 | 70 | 71 | 72 | 73 | 74 | ___ 75 | 76 | 77 | -------------------------------------------------------------------------------- /api/classes/connection.md: -------------------------------------------------------------------------------- 1 | [Mongo Portable](../README.md) > [Connection](../classes/connection.md) 2 | 3 | 4 | 5 | # Class: Connection 6 | 7 | ## Index 8 | 9 | ### Constructors 10 | 11 | * [constructor](connection.md#constructor) 12 | 13 | 14 | ### Properties 15 | 16 | * [id](connection.md#id) 17 | * [instance](connection.md#instance) 18 | * [name](connection.md#name) 19 | 20 | 21 | 22 | --- 23 | ## Constructors 24 | 25 | 26 | 27 | ### ⊕ **new Connection**(pName: *`string`*, pId: *`any`*, pInstance: *[MongoPortable](mongoportable.md)*): [Connection](connection.md) 28 | 29 | 30 | *Defined in [utils/ConnectionHelper.ts:9](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/utils/ConnectionHelper.ts#L9)* 31 | 32 | 33 | 34 | **Parameters:** 35 | 36 | | Param | Type | Description | 37 | | ------ | ------ | ------ | 38 | | pName | `string` | - | 39 | | pId | `any` | - | 40 | | pInstance | [MongoPortable](mongoportable.md) | - | 41 | 42 | 43 | 44 | 45 | 46 | **Returns:** [Connection](connection.md) 47 | 48 | --- 49 | 50 | 51 | ## Properties 52 | 53 | 54 | ### id 55 | 56 | **● id**: *`any`* 57 | 58 | *Defined in [utils/ConnectionHelper.ts:8](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/utils/ConnectionHelper.ts#L8)* 59 | 60 | 61 | 62 | 63 | 64 | ___ 65 | 66 | 67 | 68 | ### instance 69 | 70 | **● instance**: *[MongoPortable](mongoportable.md)* 71 | 72 | *Defined in [utils/ConnectionHelper.ts:9](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/utils/ConnectionHelper.ts#L9)* 73 | 74 | 75 | 76 | 77 | 78 | ___ 79 | 80 | 81 | 82 | ### name 83 | 84 | **● name**: *`string`* 85 | 86 | *Defined in [utils/ConnectionHelper.ts:7](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/utils/ConnectionHelper.ts#L7)* 87 | 88 | 89 | 90 | 91 | 92 | ___ 93 | 94 | 95 | -------------------------------------------------------------------------------- /api/classes/connectionhelper.md: -------------------------------------------------------------------------------- 1 | [Mongo Portable](../README.md) > [ConnectionHelper](../classes/connectionhelper.md) 2 | 3 | 4 | 5 | # Class: ConnectionHelper 6 | 7 | ## Index 8 | 9 | ### Constructors 10 | 11 | * [constructor](connectionhelper.md#constructor) 12 | 13 | 14 | ### Methods 15 | 16 | * [addConnection](connectionhelper.md#addconnection) 17 | * [dropConnection](connectionhelper.md#dropconnection) 18 | * [getConnection](connectionhelper.md#getconnection) 19 | * [hasConnection](connectionhelper.md#hasconnection) 20 | * [validateDatabaseName](connectionhelper.md#validatedatabasename) 21 | 22 | 23 | 24 | --- 25 | ## Constructors 26 | 27 | 28 | 29 | ### ⊕ **new ConnectionHelper**(): [ConnectionHelper](connectionhelper.md) 30 | 31 | 32 | *Defined in [utils/ConnectionHelper.ts:20](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/utils/ConnectionHelper.ts#L20)* 33 | 34 | 35 | 36 | 37 | 38 | **Returns:** [ConnectionHelper](connectionhelper.md) 39 | 40 | --- 41 | 42 | 43 | 44 | ## Methods 45 | 46 | 47 | ### addConnection 48 | 49 | ► **addConnection**(name: *`string`*, id: *`any`*, instance: *[MongoPortable](mongoportable.md)*): `void` 50 | 51 | 52 | 53 | *Defined in [utils/ConnectionHelper.ts:24](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/utils/ConnectionHelper.ts#L24)* 54 | 55 | 56 | 57 | **Parameters:** 58 | 59 | | Param | Type | Description | 60 | | ------ | ------ | ------ | 61 | | name | `string` | - | 62 | | id | `any` | - | 63 | | instance | [MongoPortable](mongoportable.md) | - | 64 | 65 | 66 | 67 | 68 | 69 | **Returns:** `void` 70 | 71 | 72 | 73 | 74 | 75 | ___ 76 | 77 | 78 | 79 | ### dropConnection 80 | 81 | ► **dropConnection**(name: *`string`*): `boolean` 82 | 83 | 84 | 85 | *Defined in [utils/ConnectionHelper.ts:40](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/utils/ConnectionHelper.ts#L40)* 86 | 87 | 88 | 89 | **Parameters:** 90 | 91 | | Param | Type | Description | 92 | | ------ | ------ | ------ | 93 | | name | `string` | - | 94 | 95 | 96 | 97 | 98 | 99 | **Returns:** `boolean` 100 | 101 | 102 | 103 | 104 | 105 | ___ 106 | 107 | 108 | 109 | ### getConnection 110 | 111 | ► **getConnection**(name: *`string`*): [Connection](connection.md) 112 | 113 | 114 | 115 | *Defined in [utils/ConnectionHelper.ts:30](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/utils/ConnectionHelper.ts#L30)* 116 | 117 | 118 | 119 | **Parameters:** 120 | 121 | | Param | Type | Description | 122 | | ------ | ------ | ------ | 123 | | name | `string` | - | 124 | 125 | 126 | 127 | 128 | 129 | **Returns:** [Connection](connection.md) 130 | 131 | 132 | 133 | 134 | 135 | ___ 136 | 137 | 138 | 139 | ### hasConnection 140 | 141 | ► **hasConnection**(name: *`string`*): `boolean` 142 | 143 | 144 | 145 | *Defined in [utils/ConnectionHelper.ts:52](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/utils/ConnectionHelper.ts#L52)* 146 | 147 | 148 | 149 | **Parameters:** 150 | 151 | | Param | Type | Description | 152 | | ------ | ------ | ------ | 153 | | name | `string` | - | 154 | 155 | 156 | 157 | 158 | 159 | **Returns:** `boolean` 160 | 161 | 162 | 163 | 164 | 165 | ___ 166 | 167 | 168 | 169 | ### «Private» validateDatabaseName 170 | 171 | ► **validateDatabaseName**(name: *`string`*): `boolean` 172 | 173 | 174 | 175 | *Defined in [utils/ConnectionHelper.ts:72](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/utils/ConnectionHelper.ts#L72)* 176 | 177 | 178 | 179 | Validates the database name 180 | *__method__*: MongoPortable#_validateDatabaseName 181 | 182 | 183 | 184 | **Parameters:** 185 | 186 | | Param | Type | Description | 187 | | ------ | ------ | ------ | 188 | | name | `string` | - | 189 | 190 | 191 | 192 | 193 | 194 | **Returns:** `boolean` 195 | "true" if the name is valid 196 | 197 | 198 | 199 | 200 | 201 | 202 | ___ 203 | 204 | 205 | -------------------------------------------------------------------------------- /api/classes/document.md: -------------------------------------------------------------------------------- 1 | [Mongo Portable](../README.md) > [Document](../classes/document.md) 2 | 3 | 4 | 5 | # Class: Document 6 | 7 | ## Index 8 | 9 | 10 | --- 11 | -------------------------------------------------------------------------------- /api/classes/eventemitter.md: -------------------------------------------------------------------------------- 1 | [Mongo Portable](../README.md) > [EventEmitter](../classes/eventemitter.md) 2 | 3 | 4 | 5 | # Class: EventEmitter 6 | 7 | ## Hierarchy 8 | 9 | **EventEmitter** 10 | 11 | ↳ [MongoPortable](mongoportable.md) 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | ## Index 21 | 22 | ### Constructors 23 | 24 | * [constructor](eventemitter.md#constructor) 25 | 26 | 27 | ### Properties 28 | 29 | * [logger](eventemitter.md#logger) 30 | 31 | 32 | ### Methods 33 | 34 | * [emit](eventemitter.md#emit) 35 | 36 | 37 | ### Object literals 38 | 39 | * [options](eventemitter.md#options) 40 | 41 | 42 | 43 | --- 44 | ## Constructors 45 | 46 | 47 | 48 | ### ⊕ **new EventEmitter**(options?: *`any`*): [EventEmitter](eventemitter.md) 49 | 50 | 51 | *Defined in [emitter/EventEmitter.ts:9](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/emitter/EventEmitter.ts#L9)* 52 | 53 | 54 | 55 | **Parameters:** 56 | 57 | | Param | Type | Default value | Description | 58 | | ------ | ------ | ------ | ------ | 59 | | options | `any` | {} | - | 60 | 61 | 62 | 63 | 64 | 65 | **Returns:** [EventEmitter](eventemitter.md) 66 | 67 | --- 68 | 69 | 70 | ## Properties 71 | 72 | 73 | ### «Protected» logger 74 | 75 | **● logger**: *`JSWLogger`* 76 | 77 | *Defined in [emitter/EventEmitter.ts:6](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/emitter/EventEmitter.ts#L6)* 78 | 79 | 80 | 81 | 82 | 83 | ___ 84 | 85 | 86 | ## Methods 87 | 88 | 89 | ### emit 90 | 91 | ► **emit**(event: *`string`*, args: *`Object`*, stores?: *`Array`.<`Object`⎮`Function`>*): `Promise`.<`void`> 92 | 93 | 94 | 95 | *Defined in [emitter/EventEmitter.ts:18](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/emitter/EventEmitter.ts#L18)* 96 | 97 | 98 | 99 | **Parameters:** 100 | 101 | | Param | Type | Default value | Description | 102 | | ------ | ------ | ------ | ------ | 103 | | event | `string` | - | - | 104 | | args | `Object` | - | - | 105 | | stores | `Array`.<`Object`⎮`Function`> | [] | - | 106 | 107 | 108 | 109 | 110 | 111 | **Returns:** `Promise`.<`void`> 112 | 113 | 114 | 115 | 116 | 117 | ___ 118 | 119 | 120 | 121 | 122 | ## Object literal: options 123 | 124 | 125 | 126 | 127 | ### log 128 | 129 | **● log**: *`object`* 130 | 131 | *Defined in [emitter/EventEmitter.ts:8](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/emitter/EventEmitter.ts#L8)* 132 | 133 | 134 | #### Type declaration 135 | 136 | 137 | 138 | 139 | 140 | ___ 141 | 142 | 143 | -------------------------------------------------------------------------------- /api/classes/options.md: -------------------------------------------------------------------------------- 1 | [Mongo Portable](../README.md) > [Options](../classes/options.md) 2 | 3 | 4 | 5 | # Class: Options 6 | 7 | ## Index 8 | 9 | ### Constructors 10 | 11 | * [constructor](options.md#constructor) 12 | 13 | 14 | ### Properties 15 | 16 | * [limit](options.md#limit) 17 | * [log](options.md#log) 18 | * [skip](options.md#skip) 19 | * [sort](options.md#sort) 20 | 21 | 22 | 23 | --- 24 | ## Constructors 25 | 26 | 27 | 28 | ### ⊕ **new Options**(options?: *`any`*): [Options](options.md) 29 | 30 | 31 | *Defined in [collection/Cursor.ts:15](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/collection/Cursor.ts#L15)* 32 | 33 | 34 | 35 | **Parameters:** 36 | 37 | | Param | Type | Description | 38 | | ------ | ------ | ------ | 39 | | options | `any` | - | 40 | 41 | 42 | 43 | 44 | 45 | **Returns:** [Options](options.md) 46 | 47 | --- 48 | 49 | 50 | ## Properties 51 | 52 | 53 | ### limit 54 | 55 | **● limit**: *`number`* 56 | 57 | *Defined in [collection/Cursor.ts:8](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/collection/Cursor.ts#L8)* 58 | 59 | 60 | 61 | 62 | 63 | ___ 64 | 65 | 66 | 67 | ### log 68 | 69 | **● log**: *`Object`* 70 | 71 | *Defined in [core/Options.ts:2](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/core/Options.ts#L2)* 72 | 73 | 74 | 75 | 76 | 77 | ___ 78 | 79 | 80 | 81 | ### skip 82 | 83 | **● skip**: *`number`* 84 | 85 | *Defined in [collection/Cursor.ts:7](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/collection/Cursor.ts#L7)* 86 | 87 | 88 | 89 | 90 | 91 | ___ 92 | 93 | 94 | 95 | ### sort 96 | 97 | **● sort**: *`any`* 98 | 99 | *Defined in [collection/Cursor.ts:9](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/collection/Cursor.ts#L9)* 100 | 101 | 102 | 103 | 104 | 105 | ___ 106 | 107 | 108 | 109 | -------------------------------------------------------------------------------- /api/classes/selector.md: -------------------------------------------------------------------------------- 1 | [Mongo Portable](../README.md) > [Selector](../classes/selector.md) 2 | 3 | 4 | 5 | # Class: Selector 6 | 7 | ## Index 8 | 9 | ### Constructors 10 | 11 | * [constructor](selector.md#constructor) 12 | 13 | 14 | ### Properties 15 | 16 | * [clauses](selector.md#clauses) 17 | * [logger](selector.md#logger) 18 | * [selector_compiled](selector.md#selector_compiled) 19 | * [AGG_FIELD_SELECTOR](selector.md#agg_field_selector) 20 | * [FIELD_SELECTOR](selector.md#field_selector) 21 | * [MATCH_SELECTOR](selector.md#match_selector) 22 | * [SORT_SELECTOR](selector.md#sort_selector) 23 | 24 | 25 | ### Methods 26 | 27 | * [___buildDocumentSelector](selector.md#___builddocumentselector) 28 | * [___buildKeypathSelector](selector.md#___buildkeypathselector) 29 | * [___buildSelector](selector.md#___buildselector) 30 | * [compile](selector.md#compile) 31 | * [compileFields](selector.md#compilefields) 32 | * [compileSort](selector.md#compilesort) 33 | * [test](selector.md#test) 34 | * [isSelectorCompiled](selector.md#isselectorcompiled) 35 | * [matches](selector.md#matches) 36 | 37 | 38 | 39 | --- 40 | ## Constructors 41 | 42 | 43 | 44 | ### ⊕ **new Selector**(selector: *`any`*, type?: *`string`*): [Selector](selector.md) 45 | 46 | 47 | *Defined in [selector/Selector.ts:25](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/selector/Selector.ts#L25)* 48 | 49 | 50 | 51 | **Parameters:** 52 | 53 | | Param | Type | Default value | Description | 54 | | ------ | ------ | ------ | ------ | 55 | | selector | `any` | - | - | 56 | | type | `string` | Selector.MATCH_SELECTOR | - | 57 | 58 | 59 | 60 | 61 | 62 | **Returns:** [Selector](selector.md) 63 | 64 | --- 65 | 66 | 67 | ## Properties 68 | 69 | 70 | ### clauses 71 | 72 | **● clauses**: *`any`* 73 | 74 | *Defined in [selector/Selector.ts:25](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/selector/Selector.ts#L25)* 75 | 76 | 77 | 78 | 79 | 80 | ___ 81 | 82 | 83 | 84 | ### «Protected» logger 85 | 86 | **● logger**: *`JSWLogger`* 87 | 88 | *Defined in [selector/Selector.ts:17](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/selector/Selector.ts#L17)* 89 | 90 | 91 | 92 | 93 | 94 | ___ 95 | 96 | 97 | 98 | ### selector_compiled 99 | 100 | **● selector_compiled**: *`any`* 101 | 102 | *Defined in [selector/Selector.ts:24](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/selector/Selector.ts#L24)* 103 | 104 | 105 | 106 | 107 | 108 | ___ 109 | 110 | 111 | 112 | ### «Static» AGG_FIELD_SELECTOR 113 | 114 | **● AGG_FIELD_SELECTOR**: *`string`* = "project" 115 | 116 | *Defined in [selector/Selector.ts:22](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/selector/Selector.ts#L22)* 117 | 118 | 119 | 120 | 121 | 122 | ___ 123 | 124 | 125 | 126 | ### «Static» FIELD_SELECTOR 127 | 128 | **● FIELD_SELECTOR**: *`string`* = "field" 129 | 130 | *Defined in [selector/Selector.ts:21](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/selector/Selector.ts#L21)* 131 | 132 | 133 | 134 | 135 | 136 | ___ 137 | 138 | 139 | 140 | ### «Static» MATCH_SELECTOR 141 | 142 | **● MATCH_SELECTOR**: *`string`* = "match" 143 | 144 | *Defined in [selector/Selector.ts:19](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/selector/Selector.ts#L19)* 145 | 146 | 147 | 148 | 149 | 150 | ___ 151 | 152 | 153 | 154 | ### «Static» SORT_SELECTOR 155 | 156 | **● SORT_SELECTOR**: *`string`* = "sort" 157 | 158 | *Defined in [selector/Selector.ts:20](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/selector/Selector.ts#L20)* 159 | 160 | 161 | 162 | 163 | 164 | ___ 165 | 166 | 167 | ## Methods 168 | 169 | 170 | ### «Private» ___buildDocumentSelector 171 | 172 | ► **___buildDocumentSelector**(key: *`any`*, value: *`any`*): [Clause](clause.md) 173 | 174 | 175 | 176 | *Defined in [selector/Selector.ts:67](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/selector/Selector.ts#L67)* 177 | 178 | 179 | 180 | **Parameters:** 181 | 182 | | Param | Type | Description | 183 | | ------ | ------ | ------ | 184 | | key | `any` | - | 185 | | value | `any` | - | 186 | 187 | 188 | 189 | 190 | 191 | **Returns:** [Clause](clause.md) 192 | 193 | 194 | 195 | 196 | 197 | ___ 198 | 199 | 200 | 201 | ### «Private» ___buildKeypathSelector 202 | 203 | ► **___buildKeypathSelector**(keypath: *`any`*, value: *`any`*): [Clause](clause.md) 204 | 205 | 206 | 207 | *Defined in [selector/Selector.ts:99](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/selector/Selector.ts#L99)* 208 | 209 | 210 | 211 | **Parameters:** 212 | 213 | | Param | Type | Description | 214 | | ------ | ------ | ------ | 215 | | keypath | `any` | - | 216 | | value | `any` | - | 217 | 218 | 219 | 220 | 221 | 222 | **Returns:** [Clause](clause.md) 223 | 224 | 225 | 226 | 227 | 228 | ___ 229 | 230 | 231 | 232 | ### «Private» ___buildSelector 233 | 234 | ► **___buildSelector**(selector: *`any`*): `Array`.<`any`> 235 | 236 | 237 | 238 | *Defined in [selector/Selector.ts:45](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/selector/Selector.ts#L45)* 239 | 240 | 241 | 242 | **Parameters:** 243 | 244 | | Param | Type | Description | 245 | | ------ | ------ | ------ | 246 | | selector | `any` | - | 247 | 248 | 249 | 250 | 251 | 252 | **Returns:** `Array`.<`any`> 253 | 254 | 255 | 256 | 257 | 258 | ___ 259 | 260 | 261 | 262 | ### compile 263 | 264 | ► **compile**(selector: *`any`*): [SelectorMatcher](selectormatcher.md) 265 | 266 | 267 | 268 | *Defined in [selector/Selector.ts:194](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/selector/Selector.ts#L194)* 269 | 270 | 271 | 272 | **Parameters:** 273 | 274 | | Param | Type | Description | 275 | | ------ | ------ | ------ | 276 | | selector | `any` | - | 277 | 278 | 279 | 280 | 281 | 282 | **Returns:** [SelectorMatcher](selectormatcher.md) 283 | 284 | 285 | 286 | 287 | 288 | ___ 289 | 290 | 291 | 292 | ### compileFields 293 | 294 | ► **compileFields**(spec: *`any`*, aggregation: *`any`*): `any` 295 | 296 | 297 | 298 | *Defined in [selector/Selector.ts:369](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/selector/Selector.ts#L369)* 299 | 300 | 301 | 302 | **Parameters:** 303 | 304 | | Param | Type | Description | 305 | | ------ | ------ | ------ | 306 | | spec | `any` | - | 307 | | aggregation | `any` | - | 308 | 309 | 310 | 311 | 312 | 313 | **Returns:** `any` 314 | 315 | 316 | 317 | 318 | 319 | ___ 320 | 321 | 322 | 323 | ### compileSort 324 | 325 | ► **compileSort**(spec: *`any`*): `any` 326 | 327 | 328 | 329 | *Defined in [selector/Selector.ts:246](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/selector/Selector.ts#L246)* 330 | 331 | 332 | 333 | **Parameters:** 334 | 335 | | Param | Type | Description | 336 | | ------ | ------ | ------ | 337 | | spec | `any` | - | 338 | 339 | 340 | 341 | 342 | 343 | **Returns:** `any` 344 | 345 | 346 | 347 | 348 | 349 | ___ 350 | 351 | 352 | 353 | ### test 354 | 355 | ► **test**(doc: *`any`*): `any` 356 | 357 | 358 | 359 | *Defined in [selector/Selector.ts:190](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/selector/Selector.ts#L190)* 360 | 361 | 362 | 363 | **Parameters:** 364 | 365 | | Param | Type | Description | 366 | | ------ | ------ | ------ | 367 | | doc | `any` | - | 368 | 369 | 370 | 371 | 372 | 373 | **Returns:** `any` 374 | 375 | 376 | 377 | 378 | 379 | ___ 380 | 381 | 382 | 383 | ### «Static» isSelectorCompiled 384 | 385 | ► **isSelectorCompiled**(selector: *`any`*): `boolean` 386 | 387 | 388 | 389 | *Defined in [selector/Selector.ts:460](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/selector/Selector.ts#L460)* 390 | 391 | 392 | 393 | **Parameters:** 394 | 395 | | Param | Type | Description | 396 | | ------ | ------ | ------ | 397 | | selector | `any` | - | 398 | 399 | 400 | 401 | 402 | 403 | **Returns:** `boolean` 404 | 405 | 406 | 407 | 408 | 409 | ___ 410 | 411 | 412 | 413 | ### «Static» matches 414 | 415 | ► **matches**(selector: *`any`*, doc: *`any`*): `any` 416 | 417 | 418 | 419 | *Defined in [selector/Selector.ts:471](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/selector/Selector.ts#L471)* 420 | 421 | 422 | 423 | **Parameters:** 424 | 425 | | Param | Type | Description | 426 | | ------ | ------ | ------ | 427 | | selector | `any` | - | 428 | | doc | `any` | - | 429 | 430 | 431 | 432 | 433 | 434 | **Returns:** `any` 435 | 436 | 437 | 438 | 439 | 440 | ___ 441 | 442 | 443 | -------------------------------------------------------------------------------- /api/classes/selectormatcher.md: -------------------------------------------------------------------------------- 1 | [Mongo Portable](../README.md) > [SelectorMatcher](../classes/selectormatcher.md) 2 | 3 | 4 | 5 | # Class: SelectorMatcher 6 | 7 | ## Index 8 | 9 | ### Constructors 10 | 11 | * [constructor](selectormatcher.md#constructor) 12 | 13 | 14 | ### Properties 15 | 16 | * [clauses](selectormatcher.md#clauses) 17 | * [logger](selectormatcher.md#logger) 18 | 19 | 20 | ### Methods 21 | 22 | * [test](selectormatcher.md#test) 23 | * [all](selectormatcher.md#all) 24 | * [cmp](selectormatcher.md#cmp) 25 | * [equal](selectormatcher.md#equal) 26 | * [in](selectormatcher.md#in) 27 | * [matches](selectormatcher.md#matches) 28 | * [matches_plus](selectormatcher.md#matches_plus) 29 | 30 | 31 | 32 | --- 33 | ## Constructors 34 | 35 | 36 | 37 | ### ⊕ **new SelectorMatcher**(selector: *`any`*): [SelectorMatcher](selectormatcher.md) 38 | 39 | 40 | *Defined in [selector/SelectorMatcher.ts:7](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/selector/SelectorMatcher.ts#L7)* 41 | 42 | 43 | 44 | **Parameters:** 45 | 46 | | Param | Type | Description | 47 | | ------ | ------ | ------ | 48 | | selector | `any` | - | 49 | 50 | 51 | 52 | 53 | 54 | **Returns:** [SelectorMatcher](selectormatcher.md) 55 | 56 | --- 57 | 58 | 59 | ## Properties 60 | 61 | 62 | ### clauses 63 | 64 | **● clauses**: *`any`* 65 | 66 | *Defined in [selector/SelectorMatcher.ts:7](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/selector/SelectorMatcher.ts#L7)* 67 | 68 | 69 | 70 | 71 | 72 | ___ 73 | 74 | 75 | 76 | ### «Protected» logger 77 | 78 | **● logger**: *`JSWLogger`* 79 | 80 | *Defined in [selector/SelectorMatcher.ts:5](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/selector/SelectorMatcher.ts#L5)* 81 | 82 | 83 | 84 | 85 | 86 | ___ 87 | 88 | 89 | ## Methods 90 | 91 | 92 | ### test 93 | 94 | ► **test**(document: *`any`*): `boolean` 95 | 96 | 97 | 98 | *Defined in [selector/SelectorMatcher.ts:15](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/selector/SelectorMatcher.ts#L15)* 99 | 100 | 101 | 102 | **Parameters:** 103 | 104 | | Param | Type | Description | 105 | | ------ | ------ | ------ | 106 | | document | `any` | - | 107 | 108 | 109 | 110 | 111 | 112 | **Returns:** `boolean` 113 | 114 | 115 | 116 | 117 | 118 | ___ 119 | 120 | 121 | 122 | ### «Static» all 123 | 124 | ► **all**(array: *`any`*, value: *`any`*): `boolean` 125 | 126 | 127 | 128 | *Defined in [selector/SelectorMatcher.ts:69](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/selector/SelectorMatcher.ts#L69)* 129 | 130 | 131 | 132 | **Parameters:** 133 | 134 | | Param | Type | Description | 135 | | ------ | ------ | ------ | 136 | | array | `any` | - | 137 | | value | `any` | - | 138 | 139 | 140 | 141 | 142 | 143 | **Returns:** `boolean` 144 | 145 | 146 | 147 | 148 | 149 | ___ 150 | 151 | 152 | 153 | ### «Static» cmp 154 | 155 | ► **cmp**(a: *`any`*, b: *`any`*): `any` 156 | 157 | 158 | 159 | *Defined in [selector/SelectorMatcher.ts:226](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/selector/SelectorMatcher.ts#L226)* 160 | 161 | 162 | 163 | **Parameters:** 164 | 165 | | Param | Type | Description | 166 | | ------ | ------ | ------ | 167 | | a | `any` | - | 168 | | b | `any` | - | 169 | 170 | 171 | 172 | 173 | 174 | **Returns:** `any` 175 | 176 | 177 | 178 | 179 | 180 | ___ 181 | 182 | 183 | 184 | ### «Static» equal 185 | 186 | ► **equal**(array: *`any`*, qval: *`any`*): `boolean` 187 | 188 | 189 | 190 | *Defined in [selector/SelectorMatcher.ts:125](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/selector/SelectorMatcher.ts#L125)* 191 | 192 | 193 | 194 | **Parameters:** 195 | 196 | | Param | Type | Description | 197 | | ------ | ------ | ------ | 198 | | array | `any` | - | 199 | | qval | `any` | - | 200 | 201 | 202 | 203 | 204 | 205 | **Returns:** `boolean` 206 | 207 | 208 | 209 | 210 | 211 | ___ 212 | 213 | 214 | 215 | ### «Static» in 216 | 217 | ► **in**(array: *`any`*, value: *`any`*): `boolean` 218 | 219 | 220 | 221 | *Defined in [selector/SelectorMatcher.ts:102](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/selector/SelectorMatcher.ts#L102)* 222 | 223 | 224 | 225 | **Parameters:** 226 | 227 | | Param | Type | Description | 228 | | ------ | ------ | ------ | 229 | | array | `any` | - | 230 | | value | `any` | - | 231 | 232 | 233 | 234 | 235 | 236 | **Returns:** `boolean` 237 | 238 | 239 | 240 | 241 | 242 | ___ 243 | 244 | 245 | 246 | ### «Static» matches 247 | 248 | ► **matches**(value: *`any`*, func: *`any`*): `any` 249 | 250 | 251 | 252 | *Defined in [selector/SelectorMatcher.ts:192](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/selector/SelectorMatcher.ts#L192)* 253 | 254 | 255 | 256 | **Parameters:** 257 | 258 | | Param | Type | Description | 259 | | ------ | ------ | ------ | 260 | | value | `any` | - | 261 | | func | `any` | - | 262 | 263 | 264 | 265 | 266 | 267 | **Returns:** `any` 268 | 269 | 270 | 271 | 272 | 273 | ___ 274 | 275 | 276 | 277 | ### «Static» matches_plus 278 | 279 | ► **matches_plus**(value: *`any`*, func: *`any`*): `any` 280 | 281 | 282 | 283 | *Defined in [selector/SelectorMatcher.ts:209](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/selector/SelectorMatcher.ts#L209)* 284 | 285 | 286 | 287 | **Parameters:** 288 | 289 | | Param | Type | Description | 290 | | ------ | ------ | ------ | 291 | | value | `any` | - | 292 | | func | `any` | - | 293 | 294 | 295 | 296 | 297 | 298 | **Returns:** `any` 299 | 300 | 301 | 302 | 303 | 304 | ___ 305 | 306 | 307 | -------------------------------------------------------------------------------- /api/classes/utils.md: -------------------------------------------------------------------------------- 1 | [Mongo Portable](../README.md) > [Utils](../classes/utils.md) 2 | 3 | 4 | 5 | # Class: Utils 6 | 7 | ## Index 8 | 9 | ### Methods 10 | 11 | * [renameObjectProperty](utils.md#renameobjectproperty) 12 | 13 | 14 | 15 | --- 16 | ## Methods 17 | 18 | 19 | ### «Static» renameObjectProperty 20 | 21 | ► **renameObjectProperty**(obj: *`any`*, property: *`any`*, newName: *`any`*): `any` 22 | 23 | 24 | 25 | *Defined in [utils/Utils.ts:7](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/utils/Utils.ts#L7)* 26 | 27 | 28 | 29 | **Parameters:** 30 | 31 | | Param | Type | Description | 32 | | ------ | ------ | ------ | 33 | | obj | `any` | - | 34 | | property | `any` | - | 35 | | newName | `any` | - | 36 | 37 | 38 | 39 | 40 | 41 | **Returns:** `any` 42 | 43 | 44 | 45 | 46 | 47 | ___ 48 | 49 | 50 | -------------------------------------------------------------------------------- /api/interfaces/iabstractstore.md: -------------------------------------------------------------------------------- 1 | [Mongo Portable](../README.md) > [IAbstractStore](../interfaces/iabstractstore.md) 2 | 3 | 4 | 5 | # Interface: IAbstractStore 6 | 7 | ## Implemented by 8 | 9 | * [BaseStore](../classes/basestore.md) 10 | 11 | 12 | ## Methods 13 | 14 | 15 | ### all 16 | 17 | ► **all**(event: *`any`*): `any`⎮`Promise`.<`any`> 18 | 19 | 20 | 21 | *Defined in [store/IAbstractStore.ts:10](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/store/IAbstractStore.ts#L10)* 22 | 23 | 24 | 25 | **Parameters:** 26 | 27 | | Param | Type | Description | 28 | | ------ | ------ | ------ | 29 | | event | `any` | - | 30 | 31 | 32 | 33 | 34 | 35 | **Returns:** `any`⎮`Promise`.<`any`> 36 | 37 | 38 | 39 | 40 | 41 | ___ 42 | 43 | 44 | 45 | ### backup 46 | 47 | ► **backup**(event: *`any`*): `any`⎮`Promise`.<`any`> 48 | 49 | 50 | 51 | *Defined in [store/IAbstractStore.ts:22](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/store/IAbstractStore.ts#L22)* 52 | 53 | 54 | 55 | **Parameters:** 56 | 57 | | Param | Type | Description | 58 | | ------ | ------ | ------ | 59 | | event | `any` | - | 60 | 61 | 62 | 63 | 64 | 65 | **Returns:** `any`⎮`Promise`.<`any`> 66 | 67 | 68 | 69 | 70 | 71 | ___ 72 | 73 | 74 | 75 | ### backups 76 | 77 | ► **backups**(event: *`any`*): `any`⎮`Promise`.<`any`> 78 | 79 | 80 | 81 | *Defined in [store/IAbstractStore.ts:24](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/store/IAbstractStore.ts#L24)* 82 | 83 | 84 | 85 | **Parameters:** 86 | 87 | | Param | Type | Description | 88 | | ------ | ------ | ------ | 89 | | event | `any` | - | 90 | 91 | 92 | 93 | 94 | 95 | **Returns:** `any`⎮`Promise`.<`any`> 96 | 97 | 98 | 99 | 100 | 101 | ___ 102 | 103 | 104 | 105 | ### createCollection 106 | 107 | ► **createCollection**(event: *`any`*): `boolean`⎮`Promise`.<`boolean`> 108 | 109 | 110 | 111 | *Defined in [store/IAbstractStore.ts:4](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/store/IAbstractStore.ts#L4)* 112 | 113 | 114 | 115 | **Parameters:** 116 | 117 | | Param | Type | Description | 118 | | ------ | ------ | ------ | 119 | | event | `any` | - | 120 | 121 | 122 | 123 | 124 | 125 | **Returns:** `boolean`⎮`Promise`.<`boolean`> 126 | 127 | 128 | 129 | 130 | 131 | ___ 132 | 133 | 134 | 135 | ### ensureIndex 136 | 137 | ► **ensureIndex**(event: *`any`*): `any`⎮`Promise`.<`any`> 138 | 139 | 140 | 141 | *Defined in [store/IAbstractStore.ts:20](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/store/IAbstractStore.ts#L20)* 142 | 143 | 144 | 145 | **Parameters:** 146 | 147 | | Param | Type | Description | 148 | | ------ | ------ | ------ | 149 | | event | `any` | - | 150 | 151 | 152 | 153 | 154 | 155 | **Returns:** `any`⎮`Promise`.<`any`> 156 | 157 | 158 | 159 | 160 | 161 | ___ 162 | 163 | 164 | 165 | ### find 166 | 167 | ► **find**(event: *`any`*): `any`⎮`Promise`.<`any`> 168 | 169 | 170 | 171 | *Defined in [store/IAbstractStore.ts:12](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/store/IAbstractStore.ts#L12)* 172 | 173 | 174 | 175 | **Parameters:** 176 | 177 | | Param | Type | Description | 178 | | ------ | ------ | ------ | 179 | | event | `any` | - | 180 | 181 | 182 | 183 | 184 | 185 | **Returns:** `any`⎮`Promise`.<`any`> 186 | 187 | 188 | 189 | 190 | 191 | ___ 192 | 193 | 194 | 195 | ### findOne 196 | 197 | ► **findOne**(event: *`any`*): `any`⎮`Promise`.<`any`> 198 | 199 | 200 | 201 | *Defined in [store/IAbstractStore.ts:14](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/store/IAbstractStore.ts#L14)* 202 | 203 | 204 | 205 | **Parameters:** 206 | 207 | | Param | Type | Description | 208 | | ------ | ------ | ------ | 209 | | event | `any` | - | 210 | 211 | 212 | 213 | 214 | 215 | **Returns:** `any`⎮`Promise`.<`any`> 216 | 217 | 218 | 219 | 220 | 221 | ___ 222 | 223 | 224 | 225 | ### insert 226 | 227 | ► **insert**(event: *`any`*): `boolean`⎮`Promise`.<`boolean`> 228 | 229 | 230 | 231 | *Defined in [store/IAbstractStore.ts:6](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/store/IAbstractStore.ts#L6)* 232 | 233 | 234 | 235 | **Parameters:** 236 | 237 | | Param | Type | Description | 238 | | ------ | ------ | ------ | 239 | | event | `any` | - | 240 | 241 | 242 | 243 | 244 | 245 | **Returns:** `boolean`⎮`Promise`.<`boolean`> 246 | 247 | 248 | 249 | 250 | 251 | ___ 252 | 253 | 254 | 255 | ### remove 256 | 257 | ► **remove**(event: *`any`*): `boolean`⎮`Promise`.<`boolean`> 258 | 259 | 260 | 261 | *Defined in [store/IAbstractStore.ts:18](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/store/IAbstractStore.ts#L18)* 262 | 263 | 264 | 265 | **Parameters:** 266 | 267 | | Param | Type | Description | 268 | | ------ | ------ | ------ | 269 | | event | `any` | - | 270 | 271 | 272 | 273 | 274 | 275 | **Returns:** `boolean`⎮`Promise`.<`boolean`> 276 | 277 | 278 | 279 | 280 | 281 | ___ 282 | 283 | 284 | 285 | ### removeBackup 286 | 287 | ► **removeBackup**(event: *`any`*): `any`⎮`Promise`.<`any`> 288 | 289 | 290 | 291 | *Defined in [store/IAbstractStore.ts:26](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/store/IAbstractStore.ts#L26)* 292 | 293 | 294 | 295 | **Parameters:** 296 | 297 | | Param | Type | Description | 298 | | ------ | ------ | ------ | 299 | | event | `any` | - | 300 | 301 | 302 | 303 | 304 | 305 | **Returns:** `any`⎮`Promise`.<`any`> 306 | 307 | 308 | 309 | 310 | 311 | ___ 312 | 313 | 314 | 315 | ### restore 316 | 317 | ► **restore**(event: *`any`*): `any`⎮`Promise`.<`any`> 318 | 319 | 320 | 321 | *Defined in [store/IAbstractStore.ts:28](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/store/IAbstractStore.ts#L28)* 322 | 323 | 324 | 325 | **Parameters:** 326 | 327 | | Param | Type | Description | 328 | | ------ | ------ | ------ | 329 | | event | `any` | - | 330 | 331 | 332 | 333 | 334 | 335 | **Returns:** `any`⎮`Promise`.<`any`> 336 | 337 | 338 | 339 | 340 | 341 | ___ 342 | 343 | 344 | 345 | ### save 346 | 347 | ► **save**(event: *`any`*): `any`⎮`Promise`.<`any`> 348 | 349 | 350 | 351 | *Defined in [store/IAbstractStore.ts:8](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/store/IAbstractStore.ts#L8)* 352 | 353 | 354 | 355 | **Parameters:** 356 | 357 | | Param | Type | Description | 358 | | ------ | ------ | ------ | 359 | | event | `any` | - | 360 | 361 | 362 | 363 | 364 | 365 | **Returns:** `any`⎮`Promise`.<`any`> 366 | 367 | 368 | 369 | 370 | 371 | ___ 372 | 373 | 374 | 375 | ### update 376 | 377 | ► **update**(event: *`any`*): `boolean`⎮`Promise`.<`boolean`> 378 | 379 | 380 | 381 | *Defined in [store/IAbstractStore.ts:16](https://github.com/EastolfiWebDev/MongoPortable/blob/b563243/src/store/IAbstractStore.ts#L16)* 382 | 383 | 384 | 385 | **Parameters:** 386 | 387 | | Param | Type | Description | 388 | | ------ | ------ | ------ | 389 | | event | `any` | - | 390 | 391 | 392 | 393 | 394 | 395 | **Returns:** `boolean`⎮`Promise`.<`boolean`> 396 | 397 | 398 | 399 | 400 | 401 | ___ 402 | 403 | 404 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mongo-portable", 3 | "version": "1.4.0", 4 | "description": "Portable Pure JS MongoDB - Based on Monglodb (https://github.com/euforic/monglodb.git) by Christian Sullivan (http://RogueSynaptics.com)", 5 | "main": "index.js", 6 | "authors": [ 7 | "Eduardo Astolfi " 8 | ], 9 | "license": "MIT", 10 | "keywords": [ 11 | "mongo", 12 | "portable", 13 | "ddbb", 14 | "no", 15 | "sql", 16 | "relational", 17 | "store", 18 | "node" 19 | ], 20 | "homepage": "https://github.com/eastolfi/MongoPortable", 21 | "ignore": [ 22 | "**/.*", 23 | "node_modules", 24 | "bower_components" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /docs/assets/images/icons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EastolfiWebDev/MongoPortable/e4d04e3d030d239536d55256dc0ba005e17c1aa9/docs/assets/images/icons.png -------------------------------------------------------------------------------- /docs/assets/images/icons@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EastolfiWebDev/MongoPortable/e4d04e3d030d239536d55256dc0ba005e17c1aa9/docs/assets/images/icons@2x.png -------------------------------------------------------------------------------- /docs/assets/images/widgets.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EastolfiWebDev/MongoPortable/e4d04e3d030d239536d55256dc0ba005e17c1aa9/docs/assets/images/widgets.png -------------------------------------------------------------------------------- /docs/assets/images/widgets@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EastolfiWebDev/MongoPortable/e4d04e3d030d239536d55256dc0ba005e17c1aa9/docs/assets/images/widgets@2x.png -------------------------------------------------------------------------------- /docs/classes/document.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Document | Mongo Portable 7 | 8 | 9 | 10 | 11 | 12 |
13 |
14 |
15 |
16 | 27 |
28 |
29 | Options 30 |
31 |
32 | All 33 |
    34 |
  • Public
  • 35 |
  • Public/Protected
  • 36 |
  • All
  • 37 |
38 |
39 | 40 | 41 | 42 | 43 |
44 |
45 | Menu 46 |
47 |
48 |
49 |
50 |
51 |
52 | 60 |

Class Document

61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |

Hierarchy

69 |
    70 |
  • 71 | Document 72 |
  • 73 |
74 |
75 |
76 | 96 |
97 |
98 | 157 |
158 |

Generated using TypeDoc

159 |
160 |
161 | 162 | 163 | 164 | -------------------------------------------------------------------------------- /gulp/tasks/build.js: -------------------------------------------------------------------------------- 1 | var gulp = require("gulp"); 2 | var del = require("del"); 3 | var minify = require("gulp-minify"); 4 | var browserify = require("browserify"); 5 | var sourcemaps = require("gulp-sourcemaps"); 6 | var source = require("vinyl-source-stream"); 7 | var buffer = require("vinyl-buffer"); 8 | 9 | gulp.task("clean:dist", function () { 10 | return del([ 11 | "dist/**/*.js" 12 | ]); 13 | }); 14 | 15 | gulp.task("bundle:app", ["clean:dist"], function() { 16 | return browserify({basedir: "./"}) 17 | .add("index.js") 18 | .bundle() 19 | .pipe(source("mongo-portable.js")) 20 | .pipe(buffer()) 21 | .pipe(sourcemaps.init({loadMaps: true})) 22 | .pipe(sourcemaps.write("./")) 23 | .pipe(gulp.dest("./dist")); 24 | }); 25 | 26 | gulp.task("compress:app", ["bundle:app"], function() { 27 | return gulp.src("dist/mongo-portable.js") 28 | .pipe(minify({ 29 | ext:{ 30 | min:".min.js" 31 | } 32 | })) 33 | .pipe(gulp.dest("dist")); 34 | }); -------------------------------------------------------------------------------- /gulp/tasks/docs.js: -------------------------------------------------------------------------------- 1 | var gulp = require('gulp'); 2 | var typedoc = require("gulp-typedoc"); 3 | var ghPages = require("gulp-gh-pages"); 4 | var conventionalChangelog = require('gulp-conventional-changelog'); 5 | 6 | gulp.task("doc:app", function (cb) { 7 | return gulp.src("./src/**/*.ts") 8 | .pipe(typedoc({ 9 | // typescript 10 | target: "es6", 11 | module: "commonjs", 12 | moduleResolution: "node", 13 | experimentalDecorators: true, 14 | emitDecoratorMetadata: true, 15 | noImplicitAny: false, 16 | suppressImplicitAnyIndexErrors: true, 17 | exclude: "**/**/index.ts", 18 | excludeExternals: true, 19 | 20 | // typedoc 21 | out: "docs", 22 | json: "docs/out.json", 23 | readme: "./README.md", 24 | mode: "file", 25 | 26 | name: "Mongo Portable", 27 | ignoreCompilerErrors: true, // true -> Cannot find name 'process' 28 | version: true 29 | })); 30 | }); 31 | 32 | gulp.task("doc:api", function (cb) { 33 | return gulp.src("./src/**/*.ts") 34 | .pipe(typedoc({ 35 | // typescript 36 | target: "es6", 37 | module: "commonjs", 38 | moduleResolution: "node", 39 | experimentalDecorators: true, 40 | emitDecoratorMetadata: true, 41 | noImplicitAny: false, 42 | suppressImplicitAnyIndexErrors: true, 43 | exclude: "**/**/index.ts", 44 | excludeExternals: true, 45 | 46 | // typedoc 47 | out: "api2", 48 | json: "api2/out.json", 49 | readme: "./README.md", 50 | mode: "file", 51 | theme: "markdown", 52 | 53 | name: "Mongo Portable", 54 | ignoreCompilerErrors: true, // true -> Cannot find name 'process' 55 | version: true 56 | })); 57 | }); 58 | 59 | gulp.task("publish:ghpages", function() { 60 | return gulp.src("./docs/**/*") 61 | .pipe(ghPages()); 62 | }); 63 | 64 | gulp.task("changelog", function () { 65 | return gulp.src("CHANGELOG.md", { 66 | buffer: false 67 | }) 68 | .pipe(conventionalChangelog({ 69 | preset: "angular", 70 | outputUnreleased: true, 71 | releaseCount: 0 72 | }, { 73 | host: "https://github.com", 74 | owner: "EastolfiWebDev", 75 | repository: "MongoPortable" 76 | })) 77 | .pipe(gulp.dest("./")); 78 | }); -------------------------------------------------------------------------------- /gulp/tasks/publish.js: -------------------------------------------------------------------------------- 1 | var gulp = require("gulp"); 2 | var fs = require("fs"); 3 | var gutil = require("gulp-util"); 4 | var bump = require("gulp-bump"); 5 | var git = require("gulp-git"); 6 | var minimist = require("minimist"); 7 | var conventionalGithubReleaser = require("conventional-github-releaser"); 8 | 9 | var knownOptions = { 10 | boolean: ["major", "minor", "patch"], 11 | alias: { major: "M", minor: "m", patch: "p" }, 12 | default: { major: false, minor: false, patch: false, M: false, m: false, p: false } 13 | }; 14 | 15 | var options = minimist(process.argv.slice(2), knownOptions); 16 | 17 | gulp.task("version", function () { 18 | var src = gulp.src(["./bower.json", "./package.json"]); 19 | // Do patch by default 20 | var stage = null; 21 | 22 | if (options.major) { 23 | stage = src.pipe(bump({type: "major"}).on("error", gutil.log)); 24 | } else if (options.minor) { 25 | stage = src.pipe(bump({type: "minor"}).on("error", gutil.log)); 26 | } else { 27 | stage = src.pipe(bump({type: "patch"}).on("error", gutil.log)); 28 | } 29 | 30 | return stage.pipe(gulp.dest("./")); 31 | }); 32 | 33 | gulp.task("commit-changes", function () { 34 | var kind = "patch"; 35 | 36 | if (options.major) { 37 | kind = "major"; 38 | } else if (options.minor) { 39 | kind = "minor"; 40 | } 41 | 42 | var version = JSON.parse(fs.readFileSync("package.json")).version; 43 | var msg = "chore(release): Release " + kind + " version (v" + version + ")"; 44 | 45 | return gulp.src(".") 46 | .pipe(git.add()) 47 | .pipe(git.commit(msg)); 48 | }); 49 | 50 | gulp.task("commit-changelog", ["changelog"], function() { 51 | return gulp.src("CHANGELOG.md") 52 | .pipe(git.add()) 53 | .pipe(git.commit("doc(changelog): Changelog up to date")); 54 | }); 55 | 56 | gulp.task("push-changes", function (cb) { 57 | git.push("origin", "master", cb); 58 | }); 59 | 60 | gulp.task("create-new-tag", function (cb) { 61 | var version = getPackageJsonVersion(); 62 | git.tag(version, "Created Tag for version: " + version, function (error) { 63 | if (error) { 64 | return cb(error); 65 | } 66 | 67 | git.push("origin", "master", {args: "--tags"}, cb); 68 | }); 69 | 70 | function getPackageJsonVersion () { 71 | // We parse the json file instead of using require because require caches 72 | // multiple calls so the version number won"t be updated 73 | return JSON.parse(fs.readFileSync("./package.json", "utf8")).version; 74 | } 75 | }); 76 | 77 | gulp.task("release:github", function (done) { 78 | conventionalGithubReleaser({ 79 | type: "oauth", 80 | token: "bb2128b43719d95467e61a861c079152986ef9ba" // change this to your own GitHub token or use an environment variable 81 | }, { 82 | preset: "angular" // Or to any other commit message convention you use. 83 | }, done); 84 | }); -------------------------------------------------------------------------------- /gulp/tasks/test.js: -------------------------------------------------------------------------------- 1 | var gulp = require("gulp"); 2 | var mochaPhantomJS = require("gulp-mocha-phantomjs"); 3 | 4 | gulp.task("test:browser", ["compress:app"], function () { 5 | return gulp.src("test/index.html", {read: false}) 6 | .pipe(mochaPhantomJS({reporter: "nyan"})); 7 | }); -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | var gulp = require("gulp"); 2 | var runSequence = require("run-sequence"); 3 | 4 | // Importing all the sub-tasks 5 | require("require-dir")("./gulp/tasks"); 6 | 7 | // Build the application and bundle it for browser 8 | gulp.task("build", function(cb) { 9 | runSequence( 10 | "build:app", // build 11 | "compress:app", // bundle + compress 12 | function(error) { 13 | if (error) { 14 | console.log(error); 15 | } 16 | 17 | cb(error); 18 | }); 19 | }); 20 | 21 | // Creates the html docs, and the .md docs 22 | gulp.task("doc", function(cb) { 23 | runSequence( 24 | "doc:app", // generate html docs 25 | "doc:api", // generate MD docs 26 | function(error) { 27 | if (error) { 28 | console.log(error); 29 | } 30 | 31 | cb(error); 32 | }); 33 | }); 34 | 35 | // Generates the application by building, testing, and documenting 36 | gulp.task("generate", function(cb) { 37 | runSequence( 38 | "test", // build + bundle + tests 39 | "doc", // generate all docs 40 | function(error) { 41 | if (error) { 42 | console.log(error); 43 | } 44 | 45 | cb(error); 46 | }); 47 | }); 48 | 49 | // Release a new version to github: 50 | // Generates the application 51 | // Updates the changelog 52 | // Bump version, push changes and release to github 53 | // Push test coveralls 54 | gulp.task("release", function(cb) { 55 | runSequence( 56 | "generate", // build + bundle + tests + docs 57 | "version", // bump version 58 | "commit-changes", // add all and commit under "relase MAJOR|MINOR|PATCH version (vVERSION)" message 59 | "commit-changelog", // generate changelog 60 | "push-changes", // push all commits to github 61 | "create-new-tag", // generate tag and push it 62 | "release:github", // generate github release 63 | "publish:coveralls", // generate and publis coveralls 64 | "publish:ghpages", 65 | function(error) { 66 | if (error) { 67 | console.log(error); 68 | } 69 | 70 | cb(error); 71 | }); 72 | }); 73 | 74 | gulp.task("default", function(cb) { 75 | runSequence( 76 | "generate", 77 | function(error) { 78 | if (error) { 79 | console.log(error); 80 | } 81 | 82 | cb(error); 83 | }); 84 | }); -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var core_1 = require("./src/core"); 4 | exports.MongoPortable = core_1.MongoPortable; 5 | var store_1 = require("./src/store"); 6 | exports.BaseStore = store_1.BaseStore; 7 | try { 8 | if (window) { 9 | window["MongoPortable"] = core_1.MongoPortable; 10 | } 11 | } 12 | catch (e) { } 13 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;AAAA,mCAA2C;AASlC,wBATA,oBAAa,CASA;AARtB,qCAAuC;AAQf,oBARf,iBAAS,CAQe;AANjC,IAAI,CAAC;IACD,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;QACT,MAAM,CAAC,eAAe,CAAC,GAAG,oBAAa,CAAC;IAC5C,CAAC;AACL,CAAC;AAAC,KAAK,CAAA,CAAC,CAAC,CAAC,CAAC,CAAC,CAAqD,CAAC"} -------------------------------------------------------------------------------- /index.ts: -------------------------------------------------------------------------------- 1 | import { MongoPortable } from "./src/core"; 2 | import { BaseStore } from "./src/store" 3 | 4 | try { 5 | if (window) { 6 | window["MongoPortable"] = MongoPortable; 7 | } 8 | } catch(e) { /* window not found -> not a browser environment */ } 9 | 10 | export { MongoPortable, BaseStore }; -------------------------------------------------------------------------------- /jsdoc.conf.json: -------------------------------------------------------------------------------- 1 | { 2 | "opts": { 3 | "destination": "./doc" 4 | }, 5 | "templates": { 6 | "default": { 7 | "includeDate": false 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /mkdocs.yml: -------------------------------------------------------------------------------- 1 | site_name: Mongo Portable 2 | repo_url: https://github.com/EastolfiWebDev/MongoPortable 3 | site_author: Eduardo Astolfi 4 | copyright: 2016 - Eduardo Astolfi 5 | 6 | docs_dir: api 7 | 8 | pages: 9 | - 'Introduction': 'index.md' 10 | - 'Mongo Portable': 'MongoPortable.md' 11 | - 'Collection': 'Collection.md' 12 | - 'Cursor': 'Cursor.md' 13 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mongo-portable", 3 | "version": "2.0.0", 4 | "description": "Portable Pure JS MongoDB - Based on Monglodb (https://github.com/euforic/monglodb.git) by Christian Sullivan (http://RogueSynaptics.com)", 5 | "author": "Eduardo Astolfi ", 6 | "keywords": [ 7 | "mongo", 8 | "portable", 9 | "ddbb", 10 | "no", 11 | "sql", 12 | "relational", 13 | "store", 14 | "node" 15 | ], 16 | "main": "index.js", 17 | "directories": { 18 | "doc": "doc", 19 | "test": "test" 20 | }, 21 | "nyc": { 22 | "include": [ 23 | "src/**/*.{js,ts,tsx}" 24 | ], 25 | "exclude": [ 26 | "**/node_modules/**", 27 | "src/**/*.d.ts", 28 | "src/**/index.ts", 29 | "index.ts" 30 | ], 31 | "extension": [ 32 | ".js", 33 | ".ts", 34 | ".tsx" 35 | ], 36 | "require": [ 37 | "source-map-support/register", 38 | "ts-node/register" 39 | ], 40 | "reporter": [ 41 | "json", 42 | "html" 43 | ], 44 | "produceSourceMap": true, 45 | "sourceMap": true, 46 | "instrument": true, 47 | "all": true 48 | }, 49 | "dependencies": { 50 | "jsw-logger": "^1.2.0", 51 | "lodash": "^4.17.4", 52 | "promise": "^8.0.1" 53 | }, 54 | "devDependencies": { 55 | "@types/mocha": "^2.2.43", 56 | "@types/node": "^7.0.4", 57 | "browserify": "^13.3.0", 58 | "chai": "^3.5.0", 59 | "conventional-github-releaser": "^1.1.3", 60 | "coveralls": "^2.11.9", 61 | "del": "^2.2.2", 62 | "depcheck": "^0.6.8", 63 | "gulp": "^3.9.1", 64 | "gulp-bump": "^2.5.1", 65 | "gulp-conventional-changelog": "^1.1.0", 66 | "gulp-coveralls": "^0.1.4", 67 | "gulp-gh-pages": "^0.5.4", 68 | "gulp-git": "^1.12.0", 69 | "gulp-minify": "0.0.14", 70 | "gulp-mocha-phantomjs": "^0.12.0", 71 | "gulp-sourcemaps": "^2.1.1", 72 | "gulp-typedoc": "^2.0.2", 73 | "gulp-util": "^3.0.8", 74 | "minimist": "^1.2.0", 75 | "mocha": "^2.5.3", 76 | "mocha-lcov-reporter": "^1.2.0", 77 | "nyc": "10.1.2", 78 | "require-dir": "^0.3.1", 79 | "run-sequence": "^1.2.2", 80 | "source-map-support": "^0.5.0", 81 | "ts-node": "^3.3.0", 82 | "tsconfig-paths": "^2.3.0", 83 | "typedoc": "^0.5.5", 84 | "typedoc-plugin-markdown": "^1.0.11", 85 | "typescript": "^2.6.1", 86 | "vinyl-buffer": "^1.0.0", 87 | "vinyl-source-stream": "^1.1.0" 88 | }, 89 | "scripts": { 90 | "doc": "gulp doc && gulp changelog", 91 | "doc.app": "gulp doc:app", 92 | "doc.api": "gulp doc:api", 93 | "test.old": "gulp test", 94 | "test": "mocha test/unit/**/*.spec.ts", 95 | "test.browser": "gulp test:browser", 96 | "test.full": "npm run build && npm run test", 97 | "test.coverage": "nyc mocha test/unit/**/*.spec.ts", 98 | "test.coveralls": "npm run test.coverage && nyc report --reporter=text-lcov | coveralls", 99 | "build": "tsc -p ./tsconfig.json", 100 | "build.w": "tsc -p ./tsconfig.json -w", 101 | "build.compress": "gulp compress:app" 102 | }, 103 | "repository": { 104 | "type": "git", 105 | "url": "git+https://github.com/EastolfiWebDev/MongoPortable.git" 106 | }, 107 | "homepage": "https://github.com/EastolfiWebDev/MongoPortable#readme", 108 | "bugs": { 109 | "url": "https://github.com/EastolfiWebDev/MongoPortable/issues" 110 | }, 111 | "license": "MIT" 112 | } 113 | -------------------------------------------------------------------------------- /src/aggregation/Aggregation.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * @file Cursor.js - based on Monglo#Cursor ({@link https://github.com/Monglo}) by Christian Sullivan | Copyright (c) 2012 4 | * @version 1.0.0 5 | * 6 | * @author Eduardo Astolfi 7 | * @copyright 2016 Eduardo Astolfi 8 | * @license MIT Licensed 9 | */ 10 | Object.defineProperty(exports, "__esModule", { value: true }); 11 | var _ = require("lodash"); 12 | var jsw_logger_1 = require("jsw-logger"); 13 | var selector_1 = require("../selector"); 14 | var collection_1 = require("../collection"); 15 | var stages = { 16 | '$project': true, 17 | '$match': true, 18 | '$redact': false, 19 | '$limit': false, 20 | '$skip': false, 21 | '$unwind': false, 22 | '$group': true, 23 | '$sample': false, 24 | '$sort': true, 25 | '$geoNear': false, 26 | '$lookup': false, 27 | '$out': false, 28 | '$indexStats': false 29 | }; 30 | var group_operators = { 31 | $sum: function (documents, new_id, new_field, value, isCount) { 32 | var new_docs = {}; 33 | for (var i = 0; i < documents.length; i++) { 34 | var doc = documents[i]; 35 | var val = value; 36 | if (!isCount) { 37 | val = doc[value.substr(1, value.length)] || 0; 38 | } 39 | if (_.hasIn(doc, new_id)) { 40 | var _id = doc[new_id]; 41 | if (!_.hasIn(new_docs, _id)) { 42 | new_docs[_id] = (_a = { 43 | _id: _id 44 | }, 45 | _a[new_field] = _.toNumber(val), 46 | _a); 47 | } 48 | else { 49 | new_docs[_id][new_field] += _.toNumber(val); 50 | } 51 | } 52 | } 53 | return new_docs; 54 | var _a; 55 | }, 56 | $avg: function (documents, new_id, new_field, value, isCount) { 57 | var new_docs = {}; 58 | for (var i = 0; i < documents.length; i++) { 59 | var doc = documents[i]; 60 | var val = value; 61 | if (!isCount) { 62 | val = doc[value.substr(1, value.length)] || 0; 63 | } 64 | if (_.hasIn(doc, new_id) || _.isNull(new_id)) { 65 | var _id = doc[new_id] || null; 66 | if (!_.hasIn(new_docs, _id)) { 67 | new_docs[_id] = (_a = { 68 | _id: _id 69 | }, 70 | _a[new_field] = _.toNumber(val), 71 | _a.__COUNT__ = 1, 72 | _a); 73 | } 74 | else { 75 | new_docs[_id][new_field] += _.toNumber(val); 76 | new_docs[_id].__COUNT__++; 77 | } 78 | } 79 | } 80 | for (var key in new_docs) { 81 | new_docs[key][new_field] = new_docs[key][new_field] / new_docs[key].__COUNT__; 82 | delete new_docs[key].__COUNT__; 83 | } 84 | return new_docs; 85 | var _a; 86 | } 87 | }; 88 | var do_single_group = function (group_id, group_stage, documents) { 89 | // var operators = {}; 90 | var docs = {}; 91 | for (var field in group_stage) { 92 | if (field !== '_id') { 93 | // handle group field 94 | // let group_key = key; 95 | var group_field = group_stage[field]; 96 | for (var key in group_field) { 97 | if (!_.hasIn(group_operators, key)) 98 | this.logger.throw("Unknown accumulator operator \"" + key + "\" for group stage"); 99 | // loop through all documents 100 | // var new_docs = {}; 101 | // for (let i = 0; i < documents.length; i++) { 102 | // let doc = documents[i]; 103 | // if (_.hasIn(doc, group_id)) { 104 | // let _id = doc[group_id]; 105 | // if (!_.hasIn(new_docs, _id)) { 106 | // new_docs[_id] = { 107 | // _id: _id, 108 | // [new_field]: value 109 | // }; 110 | // } else { 111 | // new_docs[_id][new_field] += value; 112 | // } 113 | // } 114 | // } 115 | // if (!_.hasIn(operators, key)) operators[key] = []; 116 | // operators[key].push({ 117 | // new_field: field, 118 | // value: group_field[key] 119 | // }); 120 | var count = true; 121 | if (_.isString(group_field[key])) { 122 | if (group_field[key].substr(0, 1) !== '$') 123 | this.logger.throw("Field names references in a right side assignement must be preceded by '$'"); 124 | if (!_.isFinite(_.toNumber(group_field[key]))) { 125 | count = false; 126 | } 127 | } 128 | var operator = group_operators[key]; 129 | _.merge(docs, operator(documents, group_id, field, group_field[key], count)); 130 | break; 131 | } 132 | } 133 | } 134 | return _.values(docs); 135 | }; 136 | var do_complex_group = function () { 137 | }; 138 | var do_sort = function (documents, sort_stage) { 139 | return documents.sort(new selector_1.Selector(sort_stage, selector_1.Selector.SORT_SELECTOR)); 140 | }; 141 | var do_match = function (documents, match_stage) { 142 | var cursor = new collection_1.Cursor(documents, match_stage); 143 | return cursor.fetch(); 144 | }; 145 | var do_group = function (documents, group_stage) { 146 | if (!_.hasIn(group_stage, '_id')) 147 | this.logger.throw('The field "_id" is required in the "$group" stage'); 148 | var new_id = group_stage['_id']; 149 | if (!_.isNull(new_id)) { 150 | if (new_id.substr(0, 1) !== '$') { 151 | this.logger.throw("Field names references in a right side assignement must be preceded by '$'"); 152 | } 153 | else { 154 | new_id = new_id.substr(1, new_id.length); 155 | } 156 | } 157 | if (_.isPlainObject(new_id)) { 158 | // complex_id 159 | // do_complex_group(); 160 | } 161 | else { 162 | // single_id 163 | return do_single_group(new_id, group_stage, documents); 164 | } 165 | }; 166 | var do_project = function (documents, project_stage) { 167 | return collection_1.Cursor.project(documents, project_stage, true); 168 | }; 169 | var Aggregation = /** @class */ (function () { 170 | function Aggregation(pipeline) { 171 | this.logger = jsw_logger_1.JSWLogger.instance; 172 | this.pipeline = pipeline; 173 | } 174 | Aggregation.prototype.aggregate = function (collection) { 175 | var docs = collection.docs; 176 | for (var i = 0; i < this.pipeline.length; i++) { 177 | var stage = this.pipeline[i]; 178 | for (var key in stage) { 179 | switch (key) { 180 | case '$project': 181 | docs = do_project(docs, stage[key]); 182 | break; 183 | case '$match': 184 | docs = do_match(docs, stage[key]); 185 | break; 186 | case '$group': 187 | docs = do_group(docs, stage[key]); 188 | break; 189 | case '$sort': 190 | docs = do_sort(docs, stage[key]); 191 | break; 192 | } 193 | } 194 | } 195 | return docs; // move to cursor 196 | }; 197 | Aggregation.prototype.validStage = function (stage) { 198 | if (!_.hasIn(stages, stage)) 199 | return this.logger.throw("Unknown stage \"" + stage + "\""); 200 | if (stages[stage] === false) 201 | return this.logger.throw("Unsupported stage \"" + stage + "\""); 202 | return true; 203 | }; 204 | return Aggregation; 205 | }()); 206 | exports.Aggregation = Aggregation; 207 | //# sourceMappingURL=Aggregation.js.map -------------------------------------------------------------------------------- /src/aggregation/Aggregation.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"Aggregation.js","sourceRoot":"","sources":["Aggregation.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;AAEH,0BAA0C;AAC1C,yCAA8C;AAE9C,wCAA+C;AAC/C,4CAAiD;AAEjD,IAAI,MAAM,GAAG;IACT,UAAU,EAAE,IAAI;IAChB,QAAQ,EAAE,IAAI;IACd,SAAS,EAAE,KAAK;IAChB,QAAQ,EAAE,KAAK;IACf,OAAO,EAAE,KAAK;IACd,SAAS,EAAE,KAAK;IAChB,QAAQ,EAAE,IAAI;IACd,SAAS,EAAE,KAAK;IAChB,OAAO,EAAE,IAAI;IACb,UAAU,EAAE,KAAK;IACjB,SAAS,EAAE,KAAK;IAChB,MAAM,EAAE,KAAK;IAC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AC,AAjDD,IAiDC;AAjDY,kCAAW"} -------------------------------------------------------------------------------- /src/aggregation/Aggregation.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Cursor.js - based on Monglo#Cursor ({@link https://github.com/Monglo}) by Christian Sullivan | Copyright (c) 2012 3 | * @version 1.0.0 4 | * 5 | * @author Eduardo Astolfi 6 | * @copyright 2016 Eduardo Astolfi 7 | * @license MIT Licensed 8 | */ 9 | 10 | import * as _ from "lodash"; 11 | import { JSWLogger } from "jsw-logger"; 12 | 13 | import { Selector } from "../selector"; 14 | import { Cursor } from "../collection"; 15 | 16 | var stages = { 17 | '$project': true, 18 | '$match': true, 19 | '$redact': false, 20 | '$limit': false, 21 | '$skip': false, 22 | '$unwind': false, 23 | '$group': true, 24 | '$sample': false, 25 | '$sort': true, 26 | '$geoNear': false, 27 | '$lookup': false, 28 | '$out': false, 29 | '$indexStats': false 30 | }; 31 | 32 | var group_operators = { 33 | $sum: function(documents, new_id, new_field, value, isCount) { 34 | var new_docs = {}; 35 | 36 | for (let i = 0; i < documents.length; i++) { 37 | let doc = documents[i]; 38 | let val = value; 39 | 40 | if (!isCount) { 41 | val = doc[value.substr(1, value.length)] || 0; 42 | } 43 | 44 | if (_.hasIn(doc, new_id)) { 45 | let _id = doc[new_id]; 46 | 47 | if (!_.hasIn(new_docs, _id)) { 48 | new_docs[_id] = { 49 | _id: _id, 50 | [new_field]: _.toNumber(val) 51 | }; 52 | } else { 53 | new_docs[_id][new_field] += _.toNumber(val); 54 | } 55 | } 56 | } 57 | 58 | return new_docs; 59 | }, 60 | 61 | $avg: function(documents, new_id, new_field, value, isCount) { 62 | var new_docs = {}; 63 | 64 | for (let i = 0; i < documents.length; i++) { 65 | let doc = documents[i]; 66 | let val = value; 67 | 68 | if (!isCount) { 69 | val = doc[value.substr(1, value.length)] || 0; 70 | } 71 | 72 | if (_.hasIn(doc, new_id) || _.isNull(new_id)) { 73 | let _id = doc[new_id] || null; 74 | 75 | if (!_.hasIn(new_docs, _id)) { 76 | new_docs[_id] = { 77 | _id: _id, 78 | [new_field]: _.toNumber(val), 79 | __COUNT__: 1 80 | }; 81 | } else { 82 | new_docs[_id][new_field] += _.toNumber(val); 83 | new_docs[_id].__COUNT__++; 84 | } 85 | } 86 | } 87 | 88 | for (let key in new_docs) { 89 | new_docs[key][new_field] = new_docs[key][new_field] / new_docs[key].__COUNT__; 90 | delete new_docs[key].__COUNT__; 91 | } 92 | 93 | return new_docs; 94 | } 95 | }; 96 | 97 | var do_single_group = function(group_id, group_stage, documents) { 98 | // var operators = {}; 99 | 100 | let docs = {}; 101 | 102 | for (let field in group_stage) { 103 | if (field !== '_id') { 104 | // handle group field 105 | // let group_key = key; 106 | let group_field = group_stage[field]; 107 | 108 | for (let key in group_field) { 109 | if (!_.hasIn(group_operators, key)) this.logger.throw(`Unknown accumulator operator "${key}" for group stage`); 110 | 111 | // loop through all documents 112 | // var new_docs = {}; 113 | // for (let i = 0; i < documents.length; i++) { 114 | // let doc = documents[i]; 115 | 116 | // if (_.hasIn(doc, group_id)) { 117 | // let _id = doc[group_id]; 118 | 119 | // if (!_.hasIn(new_docs, _id)) { 120 | // new_docs[_id] = { 121 | // _id: _id, 122 | // [new_field]: value 123 | // }; 124 | // } else { 125 | // new_docs[_id][new_field] += value; 126 | // } 127 | // } 128 | // } 129 | 130 | // if (!_.hasIn(operators, key)) operators[key] = []; 131 | 132 | // operators[key].push({ 133 | // new_field: field, 134 | // value: group_field[key] 135 | // }); 136 | 137 | let count = true; 138 | if (_.isString(group_field[key])) { 139 | if (group_field[key].substr(0, 1) !== '$') this.logger.throw("Field names references in a right side assignement must be preceded by '$'"); 140 | 141 | if (!_.isFinite(_.toNumber(group_field[key]))) { 142 | count = false; 143 | } 144 | } 145 | 146 | let operator = group_operators[key]; 147 | 148 | _.merge(docs, operator(documents, group_id, field, group_field[key], count)); 149 | 150 | break; 151 | } 152 | } 153 | } 154 | 155 | return _.values(docs); 156 | }; 157 | 158 | var do_complex_group = function() { 159 | 160 | }; 161 | 162 | var do_sort = function(documents, sort_stage) { 163 | return documents.sort(new Selector(sort_stage, Selector.SORT_SELECTOR)); 164 | }; 165 | 166 | var do_match = function(documents, match_stage) { 167 | var cursor = new Cursor(documents, match_stage); 168 | 169 | return cursor.fetch(); 170 | }; 171 | 172 | var do_group = function(documents, group_stage) { 173 | if (!_.hasIn(group_stage, '_id')) this.logger.throw('The field "_id" is required in the "$group" stage'); 174 | 175 | let new_id = group_stage['_id']; 176 | 177 | if (!_.isNull(new_id)) { 178 | if (new_id.substr(0, 1) !== '$') { 179 | this.logger.throw("Field names references in a right side assignement must be preceded by '$'"); 180 | } else { 181 | new_id = new_id.substr(1, new_id.length); 182 | } 183 | } 184 | 185 | if (_.isPlainObject(new_id)) { 186 | // complex_id 187 | // do_complex_group(); 188 | } else { 189 | // single_id 190 | return do_single_group(new_id, group_stage, documents); 191 | } 192 | }; 193 | 194 | var do_project = function(documents, project_stage) { 195 | return Cursor.project(documents, project_stage, true); 196 | }; 197 | 198 | export class Aggregation { 199 | protected logger: JSWLogger; 200 | 201 | pipeline; 202 | 203 | constructor(pipeline) { 204 | this.logger = JSWLogger.instance; 205 | 206 | this.pipeline = pipeline; 207 | } 208 | 209 | aggregate(collection) { 210 | var docs = collection.docs; 211 | 212 | for (let i = 0; i < this.pipeline.length; i++) { 213 | let stage = this.pipeline[i]; 214 | 215 | for (let key in stage) { 216 | switch (key) { 217 | case '$project': 218 | docs = do_project(docs, stage[key]); 219 | 220 | break; 221 | case '$match': 222 | docs = do_match(docs, stage[key]); 223 | 224 | break; 225 | case '$group': 226 | docs = do_group(docs, stage[key]); 227 | 228 | break; 229 | case '$sort': 230 | docs = do_sort(docs, stage[key]); 231 | 232 | break; 233 | } 234 | } 235 | } 236 | 237 | return docs; // move to cursor 238 | } 239 | 240 | validStage(stage) { 241 | if (!_.hasIn(stages, stage)) return this.logger.throw(`Unknown stage "${stage}"`); 242 | 243 | if (stages[stage] === false) return this.logger.throw(`Unsupported stage "${stage}"`); 244 | 245 | return true; 246 | } 247 | } -------------------------------------------------------------------------------- /src/aggregation/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | function __export(m) { 3 | for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; 4 | } 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | __export(require("./Aggregation")); 7 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /src/aggregation/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;AAAA,mCAA8B"} -------------------------------------------------------------------------------- /src/aggregation/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./Aggregation"; -------------------------------------------------------------------------------- /src/binary/BinaryParserBuffer.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var _ = require("lodash"); 4 | var jsw_logger_1 = require("jsw-logger"); 5 | /** 6 | * BinaryParserBuffer 7 | * 8 | * @module BinaryParserBuffer 9 | * @since 0.0.1 10 | * @author Eduardo Astolfi 11 | * @copyright 2016 Eduardo Astolfi 12 | * @license MIT Licensed 13 | * 14 | * @classdesc BinaryParserBuffer - based on ({@link http://jsfromhell.com/classes/binary-parser Binary Parser}) by Jonas Raoni Soares Silva 15 | */ 16 | var BinaryParserBuffer = /** @class */ (function () { 17 | function BinaryParserBuffer(bigEndian, buffer) { 18 | this.buffer = []; 19 | this.logger = jsw_logger_1.JSWLogger.instance; 20 | this.bigEndian = bigEndian || 0; 21 | if (_.isString(buffer)) { 22 | this.setBuffer(buffer); 23 | } 24 | else { 25 | this.setBuffer("" + buffer); 26 | } 27 | } 28 | BinaryParserBuffer.prototype.setBuffer = function (data) { 29 | var l, i, b; 30 | if (data) { 31 | i = l = data.length; 32 | b = this.buffer = new Array(l); 33 | for (; i; b[l - i] = data.charCodeAt(--i)) 34 | ; 35 | this.bigEndian && b.reverse(); 36 | } 37 | }; 38 | BinaryParserBuffer.prototype.hasNeededBits = function (neededBits) { 39 | return this.buffer.length >= -(-neededBits >> 3); 40 | }; 41 | BinaryParserBuffer.prototype.checkBuffer = function (neededBits) { 42 | if (!this.hasNeededBits(neededBits)) { 43 | this.logger.throw("checkBuffer::missing bytes"); 44 | } 45 | }; 46 | BinaryParserBuffer.prototype.readBits = function (start, length) { 47 | //shl fix: Henri Torgemane ~1996 (compressed by Jonas Raoni) 48 | function shl(a, b) { 49 | for (; b--; a = ((a %= 0x7fffffff + 1) & 0x40000000) == 0x40000000 ? a * 2 : (a - 0x40000000) * 2 + 0x7fffffff + 1) 50 | ; 51 | return a; 52 | } 53 | if (start < 0 || length <= 0) { 54 | return 0; 55 | } 56 | this.checkBuffer(start + length); 57 | var offsetLeft, offsetRight = start % 8, curByte = this.buffer.length - (start >> 3) - 1, lastByte = this.buffer.length + (-(start + length) >> 3), diff = curByte - lastByte, sum = ((this.buffer[curByte] >> offsetRight) & ((1 << (diff ? 8 - offsetRight : length)) - 1)) + (diff && (offsetLeft = (start + length) % 8) ? (this.buffer[lastByte++] & ((1 << offsetLeft) - 1)) << (diff-- << 3) - offsetRight : 0); 58 | for (; diff; sum += shl(this.buffer[lastByte++], (diff-- << 3) - offsetRight)) 59 | ; 60 | return sum; 61 | }; 62 | return BinaryParserBuffer; 63 | }()); 64 | exports.BinaryParserBuffer = BinaryParserBuffer; 65 | //# sourceMappingURL=BinaryParserBuffer.js.map -------------------------------------------------------------------------------- /src/binary/BinaryParserBuffer.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"BinaryParserBuffer.js","sourceRoot":"","sources":["BinaryParserBuffer.ts"],"names":[],"mappings":";;AAAA,0BAA0C;AAC1C,yCAA8C;AAE9C;;;;;;;;;;GAUG;AACH;IAMI,4BAAY,SAAS,EAAE,MAAqB;QAF5C,WAAM,GAAe,EAAE,CAAC;QAGpB,IAAI,CAAC,MAAM,GAAG,sBAAS,CAAC,QAAQ,CAAC;QAEjC,IAAI,CAAC,SAAS,GAA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CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAE9O,GAAG,CAAA,CAAC,EAAE,IAAI,EAAE,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,GAAG,WAAW,CAAC;YAAC,CAAC;QAE9E,MAAM,CAAC,GAAG,CAAC;IACf,CAAC;IACL,yBAAC;AAAD,CAAC,AAnED,IAmEC;AAEQ,gDAAkB"} -------------------------------------------------------------------------------- /src/binary/BinaryParserBuffer.ts: -------------------------------------------------------------------------------- 1 | import * as _ from "lodash"; 2 | import { JSWLogger } from "jsw-logger"; 3 | 4 | /** 5 | * BinaryParserBuffer 6 | * 7 | * @module BinaryParserBuffer 8 | * @since 0.0.1 9 | * @author Eduardo Astolfi 10 | * @copyright 2016 Eduardo Astolfi 11 | * @license MIT Licensed 12 | * 13 | * @classdesc BinaryParserBuffer - based on ({@link http://jsfromhell.com/classes/binary-parser Binary Parser}) by Jonas Raoni Soares Silva 14 | */ 15 | class BinaryParserBuffer { 16 | protected logger: JSWLogger; 17 | 18 | bigEndian: number; 19 | buffer: Array = []; 20 | 21 | constructor(bigEndian, buffer: string|number) { 22 | this.logger = JSWLogger.instance; 23 | 24 | this.bigEndian = bigEndian || 0; 25 | 26 | if (_.isString(buffer)) { 27 | this.setBuffer(buffer); 28 | } else { 29 | this.setBuffer(`${buffer}`); 30 | } 31 | } 32 | 33 | setBuffer(data: string) { 34 | var l, i, b; 35 | 36 | if (data) { 37 | i = l = data.length; 38 | b = this.buffer = new Array(l); 39 | 40 | for (; i; b[l - i] = data.charCodeAt(--i)); 41 | 42 | this.bigEndian && b.reverse(); 43 | } 44 | } 45 | 46 | hasNeededBits(neededBits) { 47 | return this.buffer.length >= -(-neededBits >> 3); 48 | } 49 | 50 | checkBuffer(neededBits) { 51 | if (!this.hasNeededBits(neededBits)) { 52 | this.logger.throw("checkBuffer::missing bytes"); 53 | } 54 | } 55 | 56 | readBits(start: number, length: number) { 57 | //shl fix: Henri Torgemane ~1996 (compressed by Jonas Raoni) 58 | 59 | function shl (a, b) { 60 | for (; b--; a = ((a %= 0x7fffffff + 1) & 0x40000000) == 0x40000000 ? a * 2 : (a - 0x40000000) * 2 + 0x7fffffff + 1); 61 | 62 | return a; 63 | } 64 | 65 | if (start < 0 || length <= 0) { 66 | return 0; 67 | } 68 | 69 | this.checkBuffer(start + length); 70 | 71 | var offsetLeft, 72 | offsetRight = start % 8, 73 | curByte = this.buffer.length - ( start >> 3 ) - 1, 74 | lastByte = this.buffer.length + ( -( start + length ) >> 3 ), 75 | diff = curByte - lastByte, 76 | sum = ((this.buffer[ curByte ] >> offsetRight) & ((1 << (diff ? 8 - offsetRight : length)) - 1)) + (diff && (offsetLeft = (start + length) % 8) ? (this.buffer[lastByte++] & ((1 << offsetLeft) - 1)) << (diff-- << 3) - offsetRight : 0); 77 | 78 | for(; diff; sum += shl(this.buffer[lastByte++], (diff-- << 3) - offsetRight)); 79 | 80 | return sum; 81 | } 82 | } 83 | 84 | export { BinaryParserBuffer }; -------------------------------------------------------------------------------- /src/binary/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var BinaryParser_1 = require("./BinaryParser"); 4 | exports.BinaryParser = BinaryParser_1.BinaryParser; 5 | var BinaryParserBuffer_1 = require("./BinaryParserBuffer"); 6 | exports.BinaryParserBuffer = BinaryParserBuffer_1.BinaryParserBuffer; 7 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /src/binary/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;AAAA,+CAA0D;AAGjD,uBAHA,2BAAY,CAGA;AAFrB,2DAAgE;AAEzC,6BAFd,uCAAkB,CAEc"} -------------------------------------------------------------------------------- /src/binary/index.ts: -------------------------------------------------------------------------------- 1 | import { BinaryParser } from "./BinaryParser"; 2 | import { BinaryParserBuffer } from "./BinaryParserBuffer"; 3 | 4 | export { BinaryParser, BinaryParserBuffer }; -------------------------------------------------------------------------------- /src/collection/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | function __export(m) { 3 | for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; 4 | } 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | __export(require("./Cursor")); 7 | __export(require("./Collection")); 8 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /src/collection/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;AAAA,8BAAyB;AACzB,kCAA6B"} -------------------------------------------------------------------------------- /src/collection/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./Cursor"; 2 | export * from "./Collection"; -------------------------------------------------------------------------------- /src/core/MongoPortable.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"MongoPortable.js","sourceRoot":"","sources":["MongoPortable.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;GAOG;AACH,0BAA6C;AAC7C,iCAA8C;AAC9C,yCAAiD;AAIjD,sCAAiD;AACjD,4CAAoD;AACpD,wCAAkD;AAClD,kCAAqD;AAErD;;;;;;;;;GASG;AACH;IAAmC,iCAAY;IAY3C,uBAAY,YAAoB,EAAE,OAAY;QAA9C,YACI,kBAAM,OAAO,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,SAkBhC;QAwPD;;;;WAIG;QACH,sBAAgB,GAAG,KAAI,CAAC,UAAU,CAAC;QA7QrC,KAAI,CAAC,MAAM,GAAG,sBAAS,CAAC,QAAQ,CAAC;QAEjC,8CAA8C;QAC9C,EAAE,CAAC,CAAC,aAAa,CAAC,WAAW,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YAC3D,MAAM,CAAC,aAAa,CAAC,WAAW,CAAC,aAAa,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CAAA,AAzjBD,CAAmC,sBAAY,GAyjB9C;AAzjBY,sCAAa"} -------------------------------------------------------------------------------- /src/core/Options.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var Options = /** @class */ (function () { 4 | function Options() { 5 | } 6 | return Options; 7 | }()); 8 | exports.Options = Options; 9 | //# sourceMappingURL=Options.js.map -------------------------------------------------------------------------------- /src/core/Options.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"Options.js","sourceRoot":"","sources":["Options.ts"],"names":[],"mappings":";;AAAA;IAAA;IAEA,CAAC;IAAD,cAAC;AAAD,CAAC,AAFD,IAEC;AAFY,0BAAO"} -------------------------------------------------------------------------------- /src/core/Options.ts: -------------------------------------------------------------------------------- 1 | export class Options { 2 | log: Object; 3 | } -------------------------------------------------------------------------------- /src/core/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | function __export(m) { 3 | for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; 4 | } 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | __export(require("./MongoPortable")); 7 | __export(require("./Options")); 8 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /src/core/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;AAAA,qCAAgC;AAChC,+BAA0B"} -------------------------------------------------------------------------------- /src/core/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./MongoPortable"; 2 | export * from "./Options"; -------------------------------------------------------------------------------- /src/document/Document.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var Document = /** @class */ (function () { 4 | function Document() { 5 | } 6 | return Document; 7 | }()); 8 | exports.Document = Document; 9 | //# sourceMappingURL=Document.js.map -------------------------------------------------------------------------------- /src/document/Document.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"Document.js","sourceRoot":"","sources":["Document.ts"],"names":[],"mappings":";;AAAA;IAAA;IAEA,CAAC;IAAD,eAAC;AAAD,CAAC,AAFD,IAEC;AAFY,4BAAQ"} -------------------------------------------------------------------------------- /src/document/Document.ts: -------------------------------------------------------------------------------- 1 | export class Document { 2 | 3 | } -------------------------------------------------------------------------------- /src/document/ObjectId.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"ObjectId.js","sourceRoot":"","sources":["ObjectId.ts"],"names":[],"mappings":";;AAAA,0BAA0C;AAC1C,yCAA8C;AAE9C,yCAAmD;AAEnD;;;;;;;;GAQG;AACH,IAAI,UAAU,GAAW,QAAQ,CAAC,KAAG,IAAI,CAAC,MAAM,EAAE,GAAG,QAAU,EAAE,EAAE,CAAC,CAAC;AAErE,+CAA+C;AAC/C,IAAI,iBAAiB,GAAG,IAAI,MAAM,CAAC,mBAAmB,CAAC,CAAC;AACxD,IAAI,gBAAgB,GAAG,UAAS,GAAG,EAAE,GAAQ;IAAR,oBAAA,EAAA,QAAQ;IACzC,EAAE,CAAC,CAAC,GAAG,CAAC,MAAM,KAAK,GAAG,IAAI,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAAC,MAAM,CAAC,IAAI,CAAC;IAEnE,MAAM,CAAC,KAAK,CAAC;AACjB,CAAC,CAAC;AAEF,IAAI,GAAG,GAAW,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,MAAM,CAAC,CAAC;AAErD,IAAI,CAAC;IACD,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;AAC7C,CAAC;AAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACT,+DAA+D;AACnE,CAAC;AAED;;;;;;;;;;;;GAYG;AACH;IAYI,kBAAY,EAAkB;QAC1B,kEAAkE;QAP9D,cAAS,GAAW,UAAU,CAAC;QASnC,IAA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E,CAAC,CAAC,CAAC;YAC9C,MAAM,IAAI,KAAK,CAAC,yFAAyF,CAAC,CAAC;QAC/G,CAAC;QAED,IAAI,GAAG,GAAG,SAAS,CAAC,MAAM,CAAC;QAE3B,IAAI,MAAM,GAAG,EAAE,EACX,MAAM,EACN,MAAM,CAAC;QAEX,GAAG,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,GAAG,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;YAC1C,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YACpC,MAAM,GAAG,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;YAE9B,MAAM,IAAI,IAAI,oBAAY,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAClD,CAAC;QAED,MAAM,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC;IAED;;;;;;;;;OASG;IACI,uBAAc,GAArB,UAAsB,IAAI;QACtB,IAAI,YAAY,GAAG,IAAI,oBAAY,EAAE,CAAC;QACtC,IAAI,EAAE,GAAG,YAAY,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QAElG,MAAM,CAAC,IAAI,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC5B,CAAC;IAED;;;;;;;OAOG;IACI,iBAAQ,GAAf;QACI,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;IAC1B,CAAC;IA7RM,cAAK,GAAW,CAAC,CAAC;IA8R7B,eAAC;CAAA,AAlSD,IAkSC;AAlSY,4BAAQ"} -------------------------------------------------------------------------------- /src/document/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | function __export(m) { 3 | for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; 4 | } 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | __export(require("./Document")); 7 | __export(require("./ObjectId")); 8 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /src/document/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;AAAA,gCAA6B;AAC7B,gCAA6B"} -------------------------------------------------------------------------------- /src/document/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./Document"; 2 | export * from "./ObjectId"; -------------------------------------------------------------------------------- /src/emitter/EventEmitter.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __values = (this && this.__values) || function (o) { 3 | var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; 4 | if (m) return m.call(o); 5 | return { 6 | next: function () { 7 | if (o && i >= o.length) o = void 0; 8 | return { value: o && o[i++], done: !o }; 9 | } 10 | }; 11 | }; 12 | Object.defineProperty(exports, "__esModule", { value: true }); 13 | var _ = require("lodash"); 14 | var Promise = require("promise"); 15 | var jsw_logger_1 = require("jsw-logger"); 16 | var EventEmitter = /** @class */ (function () { 17 | function EventEmitter(options) { 18 | if (options === void 0) { options = {}; } 19 | this.options = { 20 | log: {} 21 | }; 22 | this.options.autoRejectTimeout = options.autoRejectTimeout || 60000; 23 | this.logger = jsw_logger_1.JSWLogger.getInstance(this.options.log); 24 | } 25 | EventEmitter.prototype.emit = function (event, args, stores) { 26 | var _this = this; 27 | if (stores === void 0) { stores = []; } 28 | if (_.isNil(event) || !_.isString(event)) { 29 | throw new Error("Parameter \"event\" must be an string"); 30 | } 31 | if (_.isNil(args)) { 32 | args = {}; 33 | stores = []; 34 | } 35 | if (_.isArray(args)) { 36 | stores = args; 37 | args = {}; 38 | } 39 | this.logger.info("Emitting store event \"" + event + "\""); 40 | this.logger.debug(JSON.stringify(args)); 41 | var storesToEmit = stores.length; 42 | return new Promise(function (resolve, reject) { 43 | if (stores.length === 0) 44 | resolve(); 45 | var storesEmitted = 0; 46 | // add to options 47 | var timeout = setTimeout(function () { 48 | reject(); 49 | }, _this.options.autoRejectTimeout); 50 | try { 51 | // Send event to all the stores registered 52 | for (var stores_1 = __values(stores), stores_1_1 = stores_1.next(); !stores_1_1.done; stores_1_1 = stores_1.next()) { 53 | var store = stores_1_1.value; 54 | // Watch out 55 | if (_.isFunction(store[event])) { 56 | store[event](args) 57 | .then(function () { 58 | storesEmitted++; 59 | // Watch out 60 | if (storesEmitted === storesToEmit) { 61 | clearTimeout(timeout); 62 | resolve(); 63 | } 64 | }).catch(function (error) { 65 | clearTimeout(timeout); 66 | reject(error); 67 | }); 68 | } 69 | else { 70 | // Skip store call 71 | storesEmitted++; 72 | // Watch out 73 | if (storesEmitted === storesToEmit) { 74 | clearTimeout(timeout); 75 | resolve(); 76 | } 77 | } 78 | } 79 | } 80 | catch (e_1_1) { e_1 = { error: e_1_1 }; } 81 | finally { 82 | try { 83 | if (stores_1_1 && !stores_1_1.done && (_a = stores_1.return)) _a.call(stores_1); 84 | } 85 | finally { if (e_1) throw e_1.error; } 86 | } 87 | var e_1, _a; 88 | }); 89 | }; 90 | return EventEmitter; 91 | }()); 92 | exports.EventEmitter = EventEmitter; 93 | //# sourceMappingURL=EventEmitter.js.map -------------------------------------------------------------------------------- /src/emitter/EventEmitter.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"EventEmitter.js","sourceRoot":"","sources":["EventEmitter.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0BAAsC;AACtC,iCAAuC;AACvC,yCAA0C;AAE1C;IAMI,sBAAY,OAAiB;QAAjB,wBAAA,EAAA,YAAiB;QAJ7B,YAAO,GAAQ;YACX,GAAG,EAAE,EAAE;SACV,CAAC;QAIJ,IAAI,CAAC,OAAO,CAAC,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,IAAI,KAAK,CAAC;QAE9D,IAAI,CAAC,MAAM,GAAG,sBAAS,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,GAA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AAA;oBAAnB,IAAI,KAAK,mBAAA;oBACV,YAAY;oBACZ,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;wBAE7B,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC;6BACjB,IAAI,CAAC;4BACF,aAAa,EAAE,CAAC;4BAEhB,YAAY;4BACZ,EAAE,CAAC,CAAC,aAAa,KAAK,YAAY,CAAC,CAAC,CAAC;gCACjC,YAAY,CAAC,OAAO,CAAC,CAAC;gCAEtB,OAAO,EAAE,CAAC;4BACd,CAAC;wBACL,CAAC,CAAC,CAAC,KAAK,CAAC,UAAA,KAAK;4BACV,YAAY,CAAC,OAAO,CAAC,CAAC;4BAEtB,MAAM,CAAC,KAAK,CAAC,CAAC;wBAClB,CAAC,CAAC,CAAC;oBACP,CAAC;oBAAC,IAAI,CAAC,CAAC;wBACJ,kBAAkB;wBAClB,aAAa,EAAE,CAAC;wBAEhB,YAAY;wBACZ,EAAE,CAAC,CAAC,aAAa,KAAK,YAAY,CAAC,CAAC,CAAC;4BACjC,YAAY,CAAC,OAAO,CAAC,CAAC;4BAEtB,OAAO,EAAE,CAAC;wBACd,CAAC;oBACL,CAAC;iBACJ;;;;;;;;;;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IACL,mBAAC;AAAD,CAAC,AA7ED,IA6EC;AA7EY,oCAAY"} -------------------------------------------------------------------------------- /src/emitter/EventEmitter.t: -------------------------------------------------------------------------------- 1 | var logger = null; 2 | 3 | module.exports = function(Logger, _) { 4 | 5 | class EventEmitter { 6 | constructor() { 7 | logger = Logger.instance; 8 | } 9 | 10 | emit(name, args, cb, stores) { 11 | if (_.isNil(name) || !_.isString(name)) { 12 | throw new Error("Error on name"); 13 | } 14 | 15 | if (_.isNil(args)) { 16 | args = {}; 17 | cb = null; 18 | } 19 | 20 | if (_.isNil(cb)) { 21 | cb = null; 22 | } 23 | 24 | if (_.isFunction(args)) { 25 | cb = args; 26 | args = {}; 27 | } 28 | 29 | if (!_.isNil(stores) && _.isArray(stores)) { 30 | this._stores = stores; 31 | } 32 | 33 | var command = name; 34 | 35 | logger.info('Emitting store event ' + name); 36 | logger.debug(args); 37 | 38 | // Send event to all the stores registered 39 | _.forEach(this._stores, function (fn) { 40 | if (_.isFunction(fn[command])) { 41 | fn[command](args, cb); 42 | } 43 | }); 44 | } 45 | } 46 | 47 | return EventEmitter; 48 | }; -------------------------------------------------------------------------------- /src/emitter/EventEmitter.ts: -------------------------------------------------------------------------------- 1 | import * as _ from "lodash"; 2 | import * as Promise from "promise"; 3 | import { JSWLogger } from "jsw-logger"; 4 | 5 | export class EventEmitter { 6 | protected logger: JSWLogger; 7 | options: any = { 8 | log: {} 9 | }; 10 | 11 | constructor(options: any = {}) { 12 | 13 | this.options.autoRejectTimeout = options.autoRejectTimeout || 60000; 14 | 15 | this.logger = JSWLogger.getInstance(this.options.log); 16 | } 17 | 18 | emit(event:string, args:Object, stores: Array = []): Promise { 19 | if (_.isNil(event) || !_.isString(event)) { 20 | throw new Error("Parameter \"event\" must be an string"); 21 | } 22 | 23 | if (_.isNil(args)) { 24 | args = {}; 25 | stores = []; 26 | } 27 | 28 | if (_.isArray(args)) { 29 | stores = >args; 30 | args = {}; 31 | } 32 | 33 | this.logger.info(`Emitting store event "${event}"`); 34 | this.logger.debug(JSON.stringify(args)); 35 | 36 | let storesToEmit = stores.length; 37 | 38 | return new Promise((resolve, reject) => { 39 | if (stores.length === 0) resolve(); 40 | 41 | let storesEmitted = 0; 42 | 43 | // add to options 44 | let timeout = setTimeout(() => { 45 | reject(); 46 | }, this.options.autoRejectTimeout); 47 | 48 | // Send event to all the stores registered 49 | for (let store of stores) { 50 | // Watch out 51 | if (_.isFunction(store[event])) { 52 | 53 | store[event](args) 54 | .then(() => { 55 | storesEmitted++; 56 | 57 | // Watch out 58 | if (storesEmitted === storesToEmit) { 59 | clearTimeout(timeout); 60 | 61 | resolve(); 62 | } 63 | }).catch(error => { 64 | clearTimeout(timeout); 65 | 66 | reject(error); 67 | }); 68 | } else { 69 | // Skip store call 70 | storesEmitted++; 71 | 72 | // Watch out 73 | if (storesEmitted === storesToEmit) { 74 | clearTimeout(timeout); 75 | 76 | resolve(); 77 | } 78 | } 79 | } 80 | }); 81 | } 82 | } -------------------------------------------------------------------------------- /src/emitter/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | function __export(m) { 3 | for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; 4 | } 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | __export(require("./EventEmitter")); 7 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /src/emitter/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;AAAA,oCAA+B"} -------------------------------------------------------------------------------- /src/emitter/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./EventEmitter"; -------------------------------------------------------------------------------- /src/selector/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | function __export(m) { 3 | for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; 4 | } 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | __export(require("./Selector")); 7 | __export(require("./SelectorMatcher")); 8 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /src/selector/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;AAAA,gCAA2B;AAC3B,uCAAkC"} -------------------------------------------------------------------------------- /src/selector/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./Selector"; 2 | export * from "./SelectorMatcher"; -------------------------------------------------------------------------------- /src/store/BaseStore.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var Promise = require("promise"); 4 | var BaseStore = /** @class */ (function () { 5 | function BaseStore() { 6 | } 7 | BaseStore.prototype.createCollection = function (event) { 8 | return Promise.resolve(true); 9 | }; 10 | BaseStore.prototype.insert = function (event) { 11 | return Promise.resolve(true); 12 | }; 13 | BaseStore.prototype.save = function (event) { 14 | return Promise.resolve({}); 15 | }; 16 | BaseStore.prototype.all = function (event) { 17 | return Promise.resolve({}); 18 | }; 19 | BaseStore.prototype.find = function (event) { 20 | return Promise.resolve({}); 21 | }; 22 | BaseStore.prototype.findOne = function (event) { 23 | return Promise.resolve({}); 24 | }; 25 | BaseStore.prototype.update = function (event) { 26 | return Promise.resolve(true); 27 | }; 28 | BaseStore.prototype.remove = function (event) { 29 | return Promise.resolve(true); 30 | }; 31 | BaseStore.prototype.ensureIndex = function (event) { 32 | return Promise.resolve({}); 33 | }; 34 | BaseStore.prototype.backup = function (event) { 35 | return Promise.resolve({}); 36 | }; 37 | BaseStore.prototype.backups = function (event) { 38 | return Promise.resolve({}); 39 | }; 40 | BaseStore.prototype.removeBackup = function (event) { 41 | return Promise.resolve({}); 42 | }; 43 | BaseStore.prototype.restore = function (event) { 44 | return Promise.resolve({}); 45 | }; 46 | return BaseStore; 47 | }()); 48 | exports.BaseStore = BaseStore; 49 | //# sourceMappingURL=BaseStore.js.map -------------------------------------------------------------------------------- /src/store/BaseStore.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"BaseStore.js","sourceRoot":"","sources":["BaseStore.ts"],"names":[],"mappings":";;AAAA,iCAAmC;AAInC;IAAA;IAoDA,CAAC;IAnDA,oCAAgB,GAAhB,UAAiB,KAAK;QACrB,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAEE,0BAAM,GAAN,UAAO,KAAK;QACd,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAEE,wBAAI,GAAJ,UAAK,KAAK;QACZ,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC5B,CAAC;IAEE,uBAAG,GAAH,UAAI,KAAK;QACX,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC5B,CAAC;IAEE,wBAAI,GAAJ,UAAK,KAAK;QACZ,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC5B,CAAC;IAEE,2BAAO,GAAP,UAAQ,KAAK;QACf,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC5B,CAAC;IAEE,0BAAM,GAAN,UAAO,KAAK;QACd,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAEE,0BAAM,GAAN,UAAO,KAAK;QACd,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAEE,+BAAW,GAAX,UAAY,KAAK;QACnB,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC5B,CAAC;IAEE,0BAAM,GAAN,UAAO,KAAK;QACd,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC5B,CAAC;IAEE,2BAAO,GAAP,UAAQ,KAAK;QACf,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC5B,CAAC;IAEE,gCAAY,GAAZ,UAAa,KAAK;QACpB,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC5B,CAAC;IAEE,2BAAO,GAAP,UAAQ,KAAK;QACf,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC5B,CAAC;IACF,gBAAC;AAAD,CAAC,AApDD,IAoDC;AApDY,8BAAS"} -------------------------------------------------------------------------------- /src/store/BaseStore.ts: -------------------------------------------------------------------------------- 1 | import * as Promise from "promise"; 2 | 3 | import { IAbstractStore } from "./IAbstractStore"; 4 | 5 | export class BaseStore implements IAbstractStore { 6 | createCollection(event): boolean | Promise { 7 | return Promise.resolve(true); 8 | } 9 | 10 | insert(event): boolean | Promise { 11 | return Promise.resolve(true); 12 | } 13 | 14 | save(event): object | Promise { 15 | return Promise.resolve({}); 16 | } 17 | 18 | all(event): object | Promise { 19 | return Promise.resolve({}); 20 | } 21 | 22 | find(event): object | Promise { 23 | return Promise.resolve({}); 24 | } 25 | 26 | findOne(event): object | Promise { 27 | return Promise.resolve({}); 28 | } 29 | 30 | update(event): boolean | Promise { 31 | return Promise.resolve(true); 32 | } 33 | 34 | remove(event): boolean | Promise { 35 | return Promise.resolve(true); 36 | } 37 | 38 | ensureIndex(event): object | Promise { 39 | return Promise.resolve({}); 40 | } 41 | 42 | backup(event): object | Promise { 43 | return Promise.resolve({}); 44 | } 45 | 46 | backups(event): object | Promise { 47 | return Promise.resolve({}); 48 | } 49 | 50 | removeBackup(event): object | Promise { 51 | return Promise.resolve({}); 52 | } 53 | 54 | restore(event): object | Promise { 55 | return Promise.resolve({}); 56 | } 57 | } -------------------------------------------------------------------------------- /src/store/IAbstractStore.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | //# sourceMappingURL=IAbstractStore.js.map -------------------------------------------------------------------------------- /src/store/IAbstractStore.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"IAbstractStore.js","sourceRoot":"","sources":["IAbstractStore.ts"],"names":[],"mappings":""} -------------------------------------------------------------------------------- /src/store/IAbstractStore.ts: -------------------------------------------------------------------------------- 1 | import * as Promise from "promise"; 2 | 3 | export interface IAbstractStore { 4 | createCollection(event): boolean | Promise; 5 | 6 | insert(event): boolean | Promise; 7 | 8 | save(event): object | Promise; 9 | 10 | all(event): object | Promise; 11 | 12 | find(event): object | Promise; 13 | 14 | findOne (event): object | Promise; 15 | 16 | update(event): boolean | Promise; 17 | 18 | remove(event): boolean | Promise; 19 | 20 | ensureIndex(event): object | Promise; 21 | 22 | backup(event): object | Promise; 23 | 24 | backups(event): object | Promise; 25 | 26 | removeBackup(event): object | Promise; 27 | 28 | restore(event): object | Promise; 29 | } -------------------------------------------------------------------------------- /src/store/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | function __export(m) { 3 | for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; 4 | } 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | __export(require("./BaseStore")); 7 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /src/store/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;AAAA,iCAA4B"} -------------------------------------------------------------------------------- /src/store/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./BaseStore"; -------------------------------------------------------------------------------- /src/utils/ConnectionHelper.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __values = (this && this.__values) || function (o) { 3 | var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; 4 | if (m) return m.call(o); 5 | return { 6 | next: function () { 7 | if (o && i >= o.length) o = void 0; 8 | return { value: o && o[i++], done: !o }; 9 | } 10 | }; 11 | }; 12 | var __read = (this && this.__read) || function (o, n) { 13 | var m = typeof Symbol === "function" && o[Symbol.iterator]; 14 | if (!m) return o; 15 | var i = m.call(o), r, ar = [], e; 16 | try { 17 | while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); 18 | } 19 | catch (error) { e = { error: error }; } 20 | finally { 21 | try { 22 | if (r && !r.done && (m = i["return"])) m.call(i); 23 | } 24 | finally { if (e) throw e.error; } 25 | } 26 | return ar; 27 | }; 28 | Object.defineProperty(exports, "__esModule", { value: true }); 29 | var _ = require("lodash"); 30 | var jsw_logger_1 = require("jsw-logger"); 31 | var Connection = /** @class */ (function () { 32 | function Connection(pName, pId, pInstance) { 33 | this.name = pName; 34 | this.id = pId; 35 | this.instance = pInstance; 36 | } 37 | return Connection; 38 | }()); 39 | exports.Connection = Connection; 40 | var ConnectionHelper = /** @class */ (function () { 41 | function ConnectionHelper() { 42 | // private _pool: Array<{name: string, id: any, instance: MongoPortable}>; 43 | this._pool = []; 44 | } 45 | ConnectionHelper.prototype.addConnection = function (name, id, instance) { 46 | if (!this.hasConnection(name)) { 47 | this._pool.push(new Connection(name, id, instance)); 48 | } 49 | }; 50 | ConnectionHelper.prototype.getConnection = function (name) { 51 | try { 52 | for (var _a = __values(this._pool), _b = _a.next(); !_b.done; _b = _a.next()) { 53 | var conn = _b.value; 54 | if (conn.name === name) { 55 | return conn; 56 | } 57 | } 58 | } 59 | catch (e_1_1) { e_1 = { error: e_1_1 }; } 60 | finally { 61 | try { 62 | if (_b && !_b.done && (_c = _a.return)) _c.call(_a); 63 | } 64 | finally { if (e_1) throw e_1.error; } 65 | } 66 | return null; 67 | var e_1, _c; 68 | }; 69 | ConnectionHelper.prototype.dropConnection = function (name) { 70 | try { 71 | for (var _a = __values(this._pool.entries()), _b = _a.next(); !_b.done; _b = _a.next()) { 72 | var _c = __read(_b.value, 2), i = _c[0], conn = _c[1]; 73 | if (conn.name === name) { 74 | this._pool.splice(i, 1); 75 | return true; 76 | } 77 | } 78 | } 79 | catch (e_2_1) { e_2 = { error: e_2_1 }; } 80 | finally { 81 | try { 82 | if (_b && !_b.done && (_d = _a.return)) _d.call(_a); 83 | } 84 | finally { if (e_2) throw e_2.error; } 85 | } 86 | return false; 87 | var e_2, _d; 88 | }; 89 | ConnectionHelper.prototype.hasConnection = function (name) { 90 | try { 91 | for (var _a = __values(this._pool), _b = _a.next(); !_b.done; _b = _a.next()) { 92 | var conn = _b.value; 93 | if (conn.name === name) { 94 | return true; 95 | } 96 | } 97 | } 98 | catch (e_3_1) { e_3 = { error: e_3_1 }; } 99 | finally { 100 | try { 101 | if (_b && !_b.done && (_c = _a.return)) _c.call(_a); 102 | } 103 | finally { if (e_3) throw e_3.error; } 104 | } 105 | return false; 106 | var e_3, _c; 107 | }; 108 | /** 109 | * Validates the database name 110 | * 111 | * @method MongoPortable#_validateDatabaseName 112 | * @private 113 | * 114 | * @param {String} databaseName - The name of the database to validate 115 | * 116 | * @return {Boolean} "true" if the name is valid 117 | */ 118 | ConnectionHelper.prototype.validateDatabaseName = function (name) { 119 | var logger = jsw_logger_1.JSWLogger.instance; 120 | if (_.isNil(name) || !_.isString(name) || name.length === 0) { 121 | logger.throw("database name must be a non empty string"); 122 | } 123 | var invalidChars = [" ", ".", "$", "/", "\\"]; 124 | for (var i = 0; i < invalidChars.length; i++) { 125 | if (name.indexOf(invalidChars[i]) != -1) { 126 | logger.throw("database names cannot contain the character \"" + invalidChars[i] + "\""); 127 | return false; 128 | } 129 | } 130 | return true; 131 | }; 132 | return ConnectionHelper; 133 | }()); 134 | exports.ConnectionHelper = ConnectionHelper; 135 | //# sourceMappingURL=ConnectionHelper.js.map -------------------------------------------------------------------------------- /src/utils/ConnectionHelper.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"ConnectionHelper.js","sourceRoot":"","sources":["ConnectionHelper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0BAAgC;AAChC,yCAAyC;AAIzC;IAKC,oBAAY,KAAa,EAAE,GAAQ,EAAE,SAAwB;QAC5D,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;QAClB,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC;QACd,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;IAC3B,CAAC;IACF,iBAAC;AAAD,CAAC,AAVD,IAUC;AAVY,gCAAU;AAYvB;IAII;QAHA,0EAA0E;QACrE,UAAK,GAAsB,EAAE,CAAC;IAEnB,CAAC;IAEjB,wCAAa,GAAb,UAAc,IAAY,EAAE,EAAM,EAAE,QAAuB;QACvD,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAC5B,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,IAAI,EAAE,EAAE,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CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC;YAC7D,MAAM,CAAC,KAAK,CAAC,0CAA0C,CAAC,CAAC;QAC1D,CAAC;QAEK,IAAI,YAAY,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;QAC9C,GAAG,CAAA,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC1C,EAAE,CAAA,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;gBACrC,MAAM,CAAC,KAAK,CAAC,mDAAgD,YAAY,CAAC,CAAC,CAAC,OAAG,CAAC,CAAC;gBAE7F,MAAM,CAAC,KAAK,CAAC;YACL,CAAC;QACL,CAAC;QAED,MAAM,CAAC,IAAI,CAAC;IAChB,CAAC;IACL,uBAAC;AAAD,CAAC,AAxED,IAwEC;AAxEY,4CAAgB"} -------------------------------------------------------------------------------- /src/utils/ConnectionHelper.ts: -------------------------------------------------------------------------------- 1 | import * as _ from "lodash"; 2 | import { JSWLogger } from "jsw-logger"; 3 | 4 | import { MongoPortable } from "../core/index"; 5 | 6 | export class Connection { 7 | name: string; 8 | id: any; 9 | instance: MongoPortable; 10 | 11 | constructor(pName: string, pId: any, pInstance: MongoPortable) { 12 | this.name = pName; 13 | this.id = pId; 14 | this.instance = pInstance; 15 | } 16 | } 17 | 18 | export class ConnectionHelper { 19 | // private _pool: Array<{name: string, id: any, instance: MongoPortable}>; 20 | private _pool: Array = []; 21 | 22 | constructor() { } 23 | 24 | addConnection(name: string, id:any, instance: MongoPortable) { 25 | if (!this.hasConnection(name)) { 26 | this._pool.push(new Connection(name, id, instance)); 27 | } 28 | } 29 | 30 | getConnection(name: string): Connection { 31 | for (let conn of this._pool) { 32 | if (conn.name === name) { 33 | return conn; 34 | } 35 | } 36 | 37 | return null; 38 | } 39 | 40 | dropConnection(name: string): boolean { 41 | for (let [i, conn] of this._pool.entries()) { 42 | if (conn.name === name) { 43 | this._pool.splice(i, 1); 44 | 45 | return true; 46 | } 47 | } 48 | 49 | return false; 50 | } 51 | 52 | hasConnection(name: string): boolean { 53 | for (let conn of this._pool) { 54 | if (conn.name === name) { 55 | return true; 56 | } 57 | } 58 | 59 | return false; 60 | } 61 | 62 | /** 63 | * Validates the database name 64 | * 65 | * @method MongoPortable#_validateDatabaseName 66 | * @private 67 | * 68 | * @param {String} databaseName - The name of the database to validate 69 | * 70 | * @return {Boolean} "true" if the name is valid 71 | */ 72 | validateDatabaseName(name: string): boolean { 73 | let logger = JSWLogger.instance; 74 | 75 | if (_.isNil(name) || !_.isString(name) || name.length === 0) { 76 | logger.throw("database name must be a non empty string"); 77 | } 78 | 79 | let invalidChars = [" ", ".", "$", "/", "\\"]; 80 | for(let i = 0; i < invalidChars.length; i++) { 81 | if(name.indexOf(invalidChars[i]) != -1) { 82 | logger.throw(`database names cannot contain the character "${invalidChars[i]}"`); 83 | 84 | return false; 85 | } 86 | } 87 | 88 | return true; 89 | } 90 | } -------------------------------------------------------------------------------- /src/utils/Utils.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var _ = require("lodash"); 4 | var Utils = /** @class */ (function () { 5 | function Utils() { 6 | } 7 | /* 8 | DO NOT MUTATES! 9 | */ 10 | Utils.renameObjectProperty = function (obj, property, newName) { 11 | var newObj = _.cloneDeep(obj); 12 | // Do nothing if some name is missing or is not an string 13 | if (!_.isString(property) || !_.isString(newName)) { 14 | return newObj; 15 | } 16 | // Do nothing if the names are the same 17 | if (property == newName) { 18 | return newObj; 19 | } 20 | // Check for the old property name to 21 | // avoid a ReferenceError in strict mode. 22 | if (newObj.hasOwnProperty(property)) { 23 | newObj[newName] = newObj[property]; 24 | delete newObj[property]; 25 | } 26 | return newObj; 27 | }; 28 | return Utils; 29 | }()); 30 | exports.Utils = Utils; 31 | //# sourceMappingURL=Utils.js.map -------------------------------------------------------------------------------- /src/utils/Utils.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"Utils.js","sourceRoot":"","sources":["Utils.ts"],"names":[],"mappings":";;AAAA,0BAA4B;AAE5B;IAAA;IA0BA,CAAC;IAzBA;;OAEG;IACO,0BAAoB,GAA3B,UAA4B,GAAG,EAAE,QAAQ,EAAE,OAAO;QACpD,IAAI,MAAM,GAAG,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QAExB,yDAAyD;QACzD,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;YAChD,MAAM,CAAC,MAAM,CAAC;QAClB,CAAC;QAED,uCAAuC;QACvC,EAAE,CAAC,CAAC,QAAQ,IAAI,OAAO,CAAC,CAAC,CAAC;YACtB,MAAM,CAAC,MAAM,CAAC;QAClB,CAAC;QAED,sCAAsC;QACtC,yCAAyC;QACzC,EAAE,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YAClC,MAAM,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;YACnC,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC5B,CAAC;QAED,MAAM,CAAC,MAAM,CAAC;IAClB,CAAC;IACL,YAAC;AAAD,CAAC,AA1BD,IA0BC;AA1BY,sBAAK"} -------------------------------------------------------------------------------- /src/utils/Utils.ts: -------------------------------------------------------------------------------- 1 | import * as _ from "lodash"; 2 | 3 | export class Utils { 4 | /* 5 | DO NOT MUTATES! 6 | */ 7 | static renameObjectProperty(obj, property, newName) { 8 | let newObj = _.cloneDeep(obj); 9 | 10 | // Do nothing if some name is missing or is not an string 11 | if (!_.isString(property) || !_.isString(newName)) { 12 | return newObj; 13 | } 14 | 15 | // Do nothing if the names are the same 16 | if (property == newName) { 17 | return newObj; 18 | } 19 | 20 | // Check for the old property name to 21 | // avoid a ReferenceError in strict mode. 22 | if (newObj.hasOwnProperty(property)) { 23 | newObj[newName] = newObj[property]; 24 | delete newObj[property]; 25 | } 26 | 27 | return newObj; 28 | } 29 | } -------------------------------------------------------------------------------- /src/utils/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | function __export(m) { 3 | for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; 4 | } 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | __export(require("./ConnectionHelper")); 7 | __export(require("./Utils")); 8 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /src/utils/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;AAAA,wCAAmC;AACnC,6BAAwB"} -------------------------------------------------------------------------------- /src/utils/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./ConnectionHelper"; 2 | export * from "./Utils"; -------------------------------------------------------------------------------- /test/helper/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./test.helper"; -------------------------------------------------------------------------------- /test/helper/test.helper.ts: -------------------------------------------------------------------------------- 1 | // import "mocha"; 2 | import { expect } from "chai"; 3 | import { JSWLogger } from "jsw-logger"; 4 | 5 | export class TestHelper { 6 | static assertThrown(fnc: Function, expected: boolean) { 7 | let thrown = false; 8 | 9 | try { 10 | fnc(); 11 | } catch (error) { 12 | thrown = true; 13 | } 14 | 15 | expect(thrown).to.be.equal(expected); 16 | } 17 | 18 | static assertDependencies(deps: Array) { 19 | for (let dep of deps) { 20 | expect(dep).to.exist; 21 | } 22 | } 23 | 24 | static initLogger(showLogs: boolean = false, throwExceptions: boolean = true) { 25 | JSWLogger.__dropInstance(); 26 | JSWLogger.getInstance({ hideAllLogs: !showLogs, throwError: throwExceptions }); 27 | } 28 | } -------------------------------------------------------------------------------- /test/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Mongo Portable Browser Tests 7 | 8 | 9 | 10 | 11 | 12 |
13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /test/mocha.opts: -------------------------------------------------------------------------------- 1 | --compilers ts:ts-node/register,tsx:ts-node/register 2 | --require tsconfig-paths/register 3 | --require source-map-support/register 4 | --full-trace 5 | -------------------------------------------------------------------------------- /test/specs/1_ObjectId.js: -------------------------------------------------------------------------------- 1 | var expect = expect = require("chai").expect, 2 | Logger = require("jsw-logger").JSWLogger; 3 | 4 | var ObjectId = null; 5 | 6 | if (!!process.env.test_coverage) { 7 | ObjectId = require("../../test/coverage/lib/document/index.js").ObjectId; 8 | } else { 9 | ObjectId = require("../../src/document/index.js").ObjectId; 10 | } 11 | 12 | // Avoid logs when testing 13 | Logger.getInstance({ hideAllLogs: true }); 14 | 15 | describe("ObjectId", function() { 16 | describe("#Constructor", function() { 17 | it("should have the dependencies ready", function() { 18 | expect(ObjectId).to.exist; 19 | }); 20 | 21 | it("should be able to create a new ObjectId()", function() { 22 | var id = new ObjectId(); 23 | 24 | expect(id).to.exist; 25 | 26 | expect(id.toString()).to.be.equal(id.toJSON()); 27 | 28 | expect(id.getTimestamp().getTime() / 1000).to.be.equal(id.generationTime); 29 | }); 30 | 31 | it("should be able to create a new ObjectId(Number)", function() { 32 | var now = Date.now(); 33 | 34 | var id = new ObjectId(now); 35 | 36 | expect(id).to.exist; 37 | 38 | expect(id.toString()).to.be.equal(id.toJSON()); 39 | 40 | expect(id.getTimestamp().getTime() / 1000).to.be.equal(id.generationTime); 41 | }); 42 | 43 | it("should be able to create a new ObjectId(Hex String)", function() { 44 | var hex = "5044555b65bedb5e56000002"; 45 | 46 | var id = new ObjectId(hex); 47 | 48 | expect(id).to.exist; 49 | 50 | expect(id.toString()).to.be.equal(id.toJSON()); 51 | 52 | expect(id.equals(hex)).to.be.truly; 53 | 54 | expect(id.getTimestamp().getTime() / 1000).to.be.equal(id.generationTime); 55 | }); 56 | 57 | it("should be able to create a new ObjectId from a cached hexstring", function() { 58 | var hex = "5044555b65bedb5e56000002"; 59 | 60 | ObjectId.cacheHexString = hex; 61 | 62 | var id = new ObjectId(); 63 | 64 | expect(id).to.exist; 65 | 66 | expect(id.toString()).to.be.equal(id.toJSON()); 67 | 68 | expect(id.equals(hex)).to.be.truly; 69 | 70 | expect(id.getTimestamp().getTime() / 1000).to.be.equal(id.generationTime); 71 | }); 72 | 73 | it("should be able to create a new ObjectId from a date time", function() { 74 | var now = Date.now(); 75 | 76 | var id = ObjectId.createFromTime(now); 77 | 78 | expect(id).to.exist; 79 | 80 | expect(id.toString()).to.be.equal(id.toJSON()); 81 | 82 | expect(id.getTimestamp().getTime() / 1000).to.be.equal(id.generationTime); 83 | }); 84 | }); 85 | 86 | describe("Methods", function() { 87 | it("should be able to set the generationTime", function() { 88 | var id = new ObjectId(); 89 | 90 | expect(id).to.exist; 91 | 92 | expect(id.toString()).to.be.equal(id.toJSON()); 93 | 94 | expect(id.getTimestamp().getTime() / 1000).to.be.equal(id.generationTime); 95 | 96 | var date = new Date("2016-05-27"); 97 | 98 | id.generationTime = date.getTime(); 99 | 100 | expect(id.getTimestamp().getTime() / 1000).to.be.equal(id.generationTime); 101 | }); 102 | 103 | it("should create a new primary key (alias for a new instance)", function() { 104 | var id = ObjectId.createPk(); 105 | 106 | expect(id).to.exist; 107 | 108 | expect(id.toString()).to.be.equal(id.toJSON()); 109 | 110 | expect(id.getTimestamp().getTime() / 1000).to.be.equal(id.generationTime); 111 | }); 112 | }); 113 | }); -------------------------------------------------------------------------------- /test/unit/binary/BinaryParser.spec.ts: -------------------------------------------------------------------------------- 1 | import "mocha"; 2 | import { expect } from "chai"; 3 | 4 | import { TestHelper } from "../../helper/index"; 5 | import { BinaryParser } from "../../../src/binary/index"; 6 | 7 | TestHelper.initLogger(); 8 | 9 | describe("BinaryParser", function() { 10 | it("should let instantiate as a class", function() { 11 | var binaryParser = new BinaryParser(null, null); 12 | 13 | expect(binaryParser).to.exist; 14 | }); 15 | 16 | it("should encode and decode a float", function() { 17 | var number = 1022.6583862304688; //1022.6583862304688 18 | 19 | var encoded = BinaryParser.fromFloat(number); 20 | 21 | expect(encoded).to.exist; 22 | 23 | var decoded = BinaryParser.toFloat(encoded); 24 | 25 | expect(decoded).to.exist; 26 | 27 | expect(decoded).to.be.equal(number); 28 | 29 | // With an Infinity 30 | 31 | number = Infinity; //1022.6583862304688 32 | 33 | encoded = BinaryParser.fromFloat(number); 34 | 35 | expect(encoded).to.exist; 36 | 37 | decoded = BinaryParser.toFloat(encoded); 38 | 39 | expect(decoded).to.exist; 40 | 41 | expect(decoded).to.be.equal(number); 42 | 43 | // With an -Infinity 44 | 45 | number = -Infinity; //1022.6583862304688 46 | 47 | encoded = BinaryParser.fromFloat(number); 48 | 49 | expect(encoded).to.exist; 50 | 51 | decoded = BinaryParser.toFloat(encoded); 52 | 53 | expect(decoded).to.exist; 54 | 55 | expect(decoded).to.be.equal(number); 56 | 57 | // With an String 58 | 59 | /*number = "test"; //1022.6583862304688 60 | 61 | encoded = BinaryParser.fromFloat(number); 62 | 63 | expect(encoded).to.exist; 64 | 65 | decoded = BinaryParser.toFloat(encoded); 66 | 67 | expect(decoded).to.exist; 68 | 69 | expect(decoded).to.be.eql(NaN);*/ 70 | }); 71 | 72 | it("should encode and decode a double", function() { 73 | var number = 1022.6583862304688; 74 | 75 | var encoded = BinaryParser.fromDouble(number); 76 | 77 | expect(encoded).to.exist; 78 | 79 | var decoded = BinaryParser.toDouble(encoded); 80 | 81 | expect(decoded).to.exist; 82 | 83 | expect(decoded).to.be.equal(number); 84 | }); 85 | 86 | it("should encode and decode an integer", function() { 87 | var number = 1022; 88 | 89 | var encoded = BinaryParser.fromInt(number); 90 | 91 | expect(encoded).to.exist; 92 | 93 | var decoded = BinaryParser.toInt(encoded); 94 | 95 | expect(decoded).to.exist; 96 | 97 | expect(decoded).to.be.equal(number); 98 | 99 | number = -1; 100 | 101 | encoded = BinaryParser.fromInt(number); 102 | 103 | expect(encoded).to.exist; 104 | 105 | decoded = BinaryParser.toInt(encoded); 106 | 107 | expect(decoded).to.exist; 108 | 109 | expect(decoded).to.be.equal(number); 110 | }); 111 | 112 | it("should encode and decode a long", function() { 113 | var number = 30; 114 | 115 | var encoded = BinaryParser.fromLong(number); 116 | 117 | expect(encoded).to.exist; 118 | 119 | var decoded = BinaryParser.toLong(encoded); 120 | 121 | expect(decoded).to.exist; 122 | 123 | expect(decoded).to.be.equal(number); 124 | }); 125 | 126 | it("should encode and decode an small", function() { 127 | var number = 30; 128 | 129 | var encoded = BinaryParser.fromSmall(number); 130 | 131 | expect(encoded).to.exist; 132 | 133 | var decoded = BinaryParser.toSmall(encoded); 134 | 135 | expect(decoded).to.exist; 136 | 137 | expect(decoded).to.be.equal(number); 138 | }); 139 | 140 | it("should encode and decode a short", function() { 141 | var number = 3; 142 | 143 | var encoded = BinaryParser.fromShort(number); 144 | 145 | expect(encoded).to.exist; 146 | 147 | var decoded = BinaryParser.toShort(encoded); 148 | 149 | expect(decoded).to.exist; 150 | 151 | expect(decoded).to.be.equal(number); 152 | }); 153 | 154 | it("should encode and decode a byte", function() { 155 | var number = 3; 156 | 157 | var encoded = BinaryParser.fromByte(number); 158 | 159 | expect(encoded).to.exist; 160 | 161 | var decoded = BinaryParser.toByte(encoded); 162 | 163 | expect(decoded).to.exist; 164 | 165 | expect(decoded).to.be.equal(number); 166 | }); 167 | 168 | it("should encode and decode a word", function() { 169 | var number = 2365; 170 | 171 | var encoded = BinaryParser.fromWord(number); 172 | 173 | expect(encoded).to.exist; 174 | 175 | var decoded = BinaryParser.toWord(encoded); 176 | 177 | expect(decoded).to.exist; 178 | 179 | expect(decoded).to.be.equal(number); 180 | }); 181 | 182 | it("should encode and decode a DWord", function() { 183 | var number = 2365; 184 | 185 | var encoded = BinaryParser.fromDWord(number); 186 | 187 | expect(encoded).to.exist; 188 | 189 | var decoded = BinaryParser.toDWord(encoded); 190 | 191 | expect(decoded).to.exist; 192 | 193 | expect(decoded).to.be.equal(number); 194 | }); 195 | 196 | it("should encode and decode a QWord", function() { 197 | var number = 2365; 198 | 199 | var encoded = BinaryParser.fromQWord(number); 200 | 201 | expect(encoded).to.exist; 202 | 203 | var decoded = BinaryParser.toQWord(encoded); 204 | 205 | expect(decoded).to.exist; 206 | 207 | expect(decoded).to.be.equal(number); 208 | }); 209 | 210 | it("should encode and decode a Int32", function() { 211 | var number = 2365; 212 | 213 | var encoded = BinaryParser.encode_int32(number); 214 | 215 | expect(encoded).to.exist; 216 | 217 | // var decoded = BinaryParser.toInt(encoded); 218 | 219 | // expect(decoded).to.exist; 220 | 221 | // expect(decoded).to.be.equal(number); 222 | }); 223 | 224 | it("should encode and decode a Int64", function() { 225 | var number = 2365; 226 | 227 | var encoded = BinaryParser.encode_int64(number); 228 | 229 | expect(encoded).to.exist; 230 | 231 | // var decoded = BinaryParser.toQWord(encoded); 232 | 233 | // expect(decoded).to.exist; 234 | 235 | // expect(decoded).to.be.equal(number); 236 | }); 237 | 238 | it("should encode and decode a UTF8", function() { 239 | var number = "my string: Ê ࠁ"; 240 | 241 | var encoded = BinaryParser.encode_utf8(number); 242 | 243 | expect(encoded).to.exist; 244 | 245 | var decoded = BinaryParser.decode_utf8(encoded); 246 | 247 | expect(decoded).to.exist; 248 | 249 | expect(decoded).to.be.equal(number); 250 | }); 251 | 252 | it("should encode and decode a CString", function() { 253 | var number = 2365; 254 | 255 | var encoded = BinaryParser.encode_cstring(number); 256 | 257 | expect(encoded).to.exist; 258 | 259 | // var decoded = BinaryParser.toQWord(encoded); 260 | 261 | // expect(decoded).to.exist; 262 | 263 | // expect(decoded).to.be.equal(number); 264 | }); 265 | 266 | it("should do a H-Print", function() { 267 | var number = "h\tString"; 268 | 269 | var encoded = BinaryParser.hprint(number); 270 | 271 | expect(encoded).to.exist; 272 | 273 | // var decoded = BinaryParser.toQWord(encoded); 274 | 275 | // expect(decoded).to.exist; 276 | 277 | // expect(decoded).to.be.equal(number); 278 | }); 279 | 280 | it("should do a IL-Print", function() { 281 | var number = "il\tString"; 282 | 283 | var encoded = BinaryParser.ilprint(number); 284 | 285 | expect(encoded).to.exist; 286 | 287 | // var decoded = BinaryParser.toQWord(encoded); 288 | 289 | // expect(decoded).to.exist; 290 | 291 | // expect(decoded).to.be.equal(number); 292 | }); 293 | 294 | it("should do a HL-Print", function() { 295 | var number = "hl\tString"; 296 | 297 | var encoded = BinaryParser.hlprint(number); 298 | 299 | expect(encoded).to.exist; 300 | 301 | // var decoded = BinaryParser.toQWord(encoded); 302 | 303 | // expect(decoded).to.exist; 304 | 305 | // expect(decoded).to.be.equal(number); 306 | }); 307 | 308 | // Fails gulp 309 | it.skip("should fail when instantiating as a function (without 'new')", function() { 310 | expect(BinaryParser).to.throw(Error); 311 | }); 312 | }); -------------------------------------------------------------------------------- /test/unit/binary/BinaryParserBuffer.spec.ts: -------------------------------------------------------------------------------- 1 | import "mocha"; 2 | import { expect } from "chai"; 3 | 4 | import { TestHelper } from "../../helper/index"; 5 | import { BinaryParserBuffer } from "../../../src/binary/index"; 6 | 7 | TestHelper.initLogger(); 8 | 9 | describe("BinaryParserBuffer", function() { 10 | describe("#Constructor", function() { 11 | it("should have the dependencies ready", function() { 12 | expect(BinaryParserBuffer).to.exist; 13 | }); 14 | 15 | it("should be able to instantiate with or without 'bigEndian' param", function() { 16 | let bpb = new BinaryParserBuffer(null, "11"); 17 | 18 | expect(bpb).to.exist; 19 | 20 | bpb = new BinaryParserBuffer(true, "11"); 21 | 22 | expect(bpb).to.exist; 23 | 24 | bpb = new BinaryParserBuffer(false, "11"); 25 | 26 | expect(bpb).to.exist; 27 | }); 28 | it("should be able to instantiate with 'buffer' string param", function() { 29 | let bpb = new BinaryParserBuffer(1, "112233"); 30 | 31 | expect(bpb).to.exist; 32 | }); 33 | it("should be able to instantiate with 'buffer' number param", function() { 34 | let bpb = new BinaryParserBuffer(1, 112233); 35 | 36 | expect(bpb).to.exist; 37 | }); 38 | }); 39 | 40 | describe("#Buffer", function() { 41 | describe("- setBuffer", function() { 42 | it("should work", function() { 43 | let bpb = new BinaryParserBuffer(null, "123"); 44 | let buff = "123456789"; 45 | 46 | bpb.setBuffer(buff); 47 | 48 | expect(bpb.buffer).to.exist; 49 | expect(bpb.buffer.length).to.be.equal(buff.length); 50 | }); 51 | }); 52 | 53 | describe("- hasNeededBits", function() { 54 | it("should work", function() { 55 | let bpb = new BinaryParserBuffer(null, "AAA"); 56 | 57 | expect(bpb.buffer).to.exist; 58 | 59 | let needed = bpb.hasNeededBits(16); 60 | 61 | expect(needed).to.be.true; 62 | 63 | needed = bpb.hasNeededBits(32); 64 | 65 | expect(needed).to.be.false; 66 | }); 67 | }); 68 | 69 | describe("- checkBuffer", function() { 70 | it("should work", function() { 71 | TestHelper.assertThrown(() => { 72 | let bpb = new BinaryParserBuffer(null, "AAA"); 73 | 74 | bpb.checkBuffer(16); 75 | }, false); 76 | 77 | TestHelper.assertThrown(() => { 78 | let bpb = new BinaryParserBuffer(null, "AAA"); 79 | 80 | bpb.checkBuffer(32); 81 | }, true); 82 | }); 83 | }); 84 | 85 | describe("- readBits", function() { 86 | it("should work", function() { 87 | let bpb = new BinaryParserBuffer(null, "12345678"); 88 | 89 | let read = bpb.readBits(0, 8); 90 | 91 | expect(read).to.exist; 92 | }); 93 | }); 94 | }); 95 | }); -------------------------------------------------------------------------------- /test/unit/core/Options.spec.t_: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EastolfiWebDev/MongoPortable/e4d04e3d030d239536d55256dc0ba005e17c1aa9/test/unit/core/Options.spec.t_ -------------------------------------------------------------------------------- /test/unit/document/Document.spec.ts: -------------------------------------------------------------------------------- 1 | import "mocha"; 2 | import { expect } from "chai"; 3 | 4 | import { TestHelper } from "../../helper/index"; 5 | import { Document } from "../../../src/document/index"; 6 | 7 | TestHelper.initLogger(); 8 | 9 | describe("Document", function() { 10 | describe("- Constructor", function() { 11 | it("should have the dependencies ready", function() { 12 | TestHelper.assertDependencies([Document]); 13 | }); 14 | }); 15 | }); -------------------------------------------------------------------------------- /test/unit/document/ObjectId.spec.ts: -------------------------------------------------------------------------------- 1 | import "mocha"; 2 | import { expect } from "chai"; 3 | 4 | import { TestHelper } from "../../helper/index"; 5 | import { ObjectId } from "../../../src/document/index"; 6 | 7 | TestHelper.initLogger(); 8 | 9 | describe("ObjectId", function() { 10 | describe("#Constructor", function() { 11 | it("should have the dependencies ready", function() { 12 | TestHelper.assertDependencies([ObjectId]); 13 | }); 14 | 15 | it("should be able to create a new ObjectId()", function() { 16 | var id = new ObjectId(); 17 | 18 | expect(id).to.exist; 19 | 20 | expect(id.toString()).to.be.equal(id.toJSON()); 21 | 22 | expect(id.getTimestamp().getTime() / 1000).to.be.equal(id.generationTime); 23 | }); 24 | 25 | it("should be able to create a new ObjectId(Number)", function() { 26 | var now = Date.now(); 27 | 28 | var id = new ObjectId(now); 29 | 30 | expect(id).to.exist; 31 | 32 | expect(id.toString()).to.be.equal(id.toJSON()); 33 | 34 | expect(id.getTimestamp().getTime() / 1000).to.be.equal(id.generationTime); 35 | }); 36 | 37 | it("should be able to create a new ObjectId(Hex String)", function() { 38 | var hex = "5044555b65bedb5e56000002"; 39 | 40 | var id = new ObjectId(hex); 41 | 42 | expect(id).to.exist; 43 | 44 | expect(id.toString()).to.be.equal(id.toJSON()); 45 | 46 | expect(id.equals(hex)).to.be.truly; 47 | 48 | expect(id.getTimestamp().getTime() / 1000).to.be.equal(id.generationTime); 49 | }); 50 | /* 51 | it("should be able to create a new ObjectId from a cached hexstring", function() { 52 | var hex = "5044555b65bedb5e56000002"; 53 | 54 | ObjectId.cacheHexString = hex; 55 | 56 | var id = new ObjectId(); 57 | 58 | expect(id).to.exist; 59 | 60 | expect(id.toString()).to.be.equal(id.toJSON()); 61 | 62 | expect(id.equals(hex)).to.be.truly; 63 | 64 | expect(id.getTimestamp().getTime() / 1000).to.be.equal(id.generationTime); 65 | }); 66 | */ 67 | it("should be able to create a new ObjectId from a date time", function() { 68 | var now = Date.now(); 69 | 70 | var id = ObjectId.createFromTime(now); 71 | 72 | expect(id).to.exist; 73 | 74 | expect(id.toString()).to.be.equal(id.toJSON()); 75 | 76 | expect(id.getTimestamp().getTime() / 1000).to.be.equal(id.generationTime); 77 | }); 78 | }); 79 | 80 | describe("Methods", function() { 81 | it("should be able to set the generationTime", function() { 82 | var id = new ObjectId(); 83 | 84 | expect(id).to.exist; 85 | 86 | expect(id.toString()).to.be.equal(id.toJSON()); 87 | 88 | expect(id.getTimestamp().getTime() / 1000).to.be.equal(id.generationTime); 89 | 90 | var date = new Date("2016-05-27"); 91 | 92 | id.generationTime = date.getTime(); 93 | 94 | expect(id.getTimestamp().getTime() / 1000).to.be.equal(id.generationTime); 95 | }); 96 | 97 | it("should create a new primary key (alias for a new instance)", function() { 98 | var id = ObjectId.createPk(); 99 | 100 | expect(id).to.exist; 101 | 102 | expect(id.toString()).to.be.equal(id.toJSON()); 103 | 104 | expect(id.getTimestamp().getTime() / 1000).to.be.equal(id.generationTime); 105 | }); 106 | }); 107 | }); -------------------------------------------------------------------------------- /test/unit/emitter/EventEmitter.spec.ts: -------------------------------------------------------------------------------- 1 | import "mocha"; 2 | import { expect } from "chai"; 3 | 4 | import { TestHelper } from "../../helper/index"; 5 | import { EventEmitter } from "../../../src/emitter/index"; 6 | 7 | TestHelper.initLogger(); 8 | 9 | describe("- EventEmitter", function() { 10 | describe("#Constructor", function() { 11 | it("should have the dependencies ready", function() { 12 | TestHelper.assertDependencies([EventEmitter]); 13 | }); 14 | 15 | it("should be able to instanciate", function() { 16 | let emitter = new EventEmitter(); 17 | 18 | expect(emitter).to.exist; 19 | }); 20 | }); 21 | 22 | describe("#Emit", function() { 23 | it("should emit an event", function(done) { 24 | TestHelper.assertThrown(() => { 25 | let emitter = new EventEmitter({ autoRejectTimeout: 1500 }); 26 | 27 | let fnc = function(data) { 28 | expect(data).to.have.property("result"); 29 | 30 | return Promise.resolve(); 31 | }; 32 | let store1 = function() { 33 | this.test = fnc; 34 | }; 35 | let store2 = { 36 | test: fnc 37 | }; 38 | 39 | emitter.emit("test", { result: "OK" }, [new store1(), store2]) 40 | .then(() => { 41 | done(); 42 | }).catch(error => { 43 | expect(error).to.not.exist; 44 | 45 | done(); 46 | }); 47 | }, false); 48 | }); 49 | }); 50 | }); -------------------------------------------------------------------------------- /test/unit/selector/SelectorMatcher.spec.ts: -------------------------------------------------------------------------------- 1 | import "mocha"; 2 | import { expect } from "chai"; 3 | 4 | import { TestHelper } from "../../helper/index"; 5 | import { SelectorMatcher } from "../../../src/selector/index"; 6 | 7 | TestHelper.initLogger(); 8 | 9 | describe("SelectorMatcher", function() { 10 | describe("- Constructor", function() { 11 | it("should have the dependencies ready", function() { 12 | TestHelper.assertDependencies([SelectorMatcher]); 13 | }); 14 | }); 15 | }); -------------------------------------------------------------------------------- /test/unit/store/BaseStore.spec.ts: -------------------------------------------------------------------------------- 1 | import "mocha"; 2 | import { expect } from "chai"; 3 | 4 | import { TestHelper } from "../../helper/index"; 5 | import { MongoPortable } from "../../../src/core/index"; 6 | import { BaseStore } from "../../../src/store/index"; 7 | 8 | TestHelper.initLogger(); 9 | 10 | let db = null; 11 | 12 | describe("- BaseStore", function() { 13 | describe("#Constructor", function() { 14 | it("should have the dependencies ready", function() { 15 | TestHelper.assertDependencies([MongoPortable, BaseStore]); 16 | }); 17 | 18 | it("should be able to instanciate", function() { 19 | let store = new BaseStore(); 20 | 21 | expect(store).to.exist; 22 | }); 23 | }); 24 | 25 | describe("#Emit", function() { 26 | before(function() { 27 | db = new MongoPortable("PRUEBAS", null); 28 | 29 | db.addStore(new BaseStore()); 30 | }); 31 | 32 | it("should emit a 'createCollection' event", function(done) { 33 | db.emit("createCollection", {}) 34 | .then((result) => { 35 | // Result: void 36 | expect(result).to.not.exist; 37 | 38 | done(); 39 | }).catch(error => { 40 | expect(error).to.not.exist; 41 | 42 | done(); 43 | }); 44 | }); 45 | 46 | it("should emit a 'insert' event", function(done) { 47 | db.emit("insert", {}) 48 | .then((result) => { 49 | // Result: void 50 | expect(result).to.not.exist; 51 | 52 | done(); 53 | }).catch(error => { 54 | expect(error).to.not.exist; 55 | 56 | done(); 57 | }); 58 | }); 59 | 60 | it("should emit a 'save' event", function(done) { 61 | db.emit("save", {}) 62 | .then((result) => { 63 | // Result: void 64 | expect(result).to.not.exist; 65 | 66 | done(); 67 | }).catch(error => { 68 | expect(error).to.not.exist; 69 | 70 | done(); 71 | }); 72 | }); 73 | 74 | it("should emit a 'all' event", function(done) { 75 | db.emit("all", {}) 76 | .then((result) => { 77 | // Result: void 78 | expect(result).to.not.exist; 79 | 80 | done(); 81 | }).catch(error => { 82 | expect(error).to.not.exist; 83 | 84 | done(); 85 | }); 86 | }); 87 | 88 | it("should emit a 'find' event", function(done) { 89 | db.emit("find", {}) 90 | .then((result) => { 91 | // Result: void 92 | expect(result).to.not.exist; 93 | 94 | done(); 95 | }).catch(error => { 96 | expect(error).to.not.exist; 97 | 98 | done(); 99 | }); 100 | }); 101 | 102 | it("should emit a 'findOne' event", function(done) { 103 | db.emit("findOne", {}) 104 | .then((result) => { 105 | // Result: void 106 | expect(result).to.not.exist; 107 | 108 | done(); 109 | }).catch(error => { 110 | expect(error).to.not.exist; 111 | 112 | done(); 113 | }); 114 | }); 115 | 116 | it("should emit a 'update' event", function(done) { 117 | db.emit("update", {}) 118 | .then((result) => { 119 | // Result: void 120 | expect(result).to.not.exist; 121 | 122 | done(); 123 | }).catch(error => { 124 | expect(error).to.not.exist; 125 | 126 | done(); 127 | }); 128 | }); 129 | 130 | it("should emit a 'remove' event", function(done) { 131 | db.emit("remove", {}) 132 | .then((result) => { 133 | // Result: void 134 | expect(result).to.not.exist; 135 | 136 | done(); 137 | }).catch(error => { 138 | expect(error).to.not.exist; 139 | 140 | done(); 141 | }); 142 | }); 143 | 144 | it("should emit a 'ensureIndex' event", function(done) { 145 | db.emit("ensureIndex", {}) 146 | .then((result) => { 147 | // Result: void 148 | expect(result).to.not.exist; 149 | 150 | done(); 151 | }).catch(error => { 152 | expect(error).to.not.exist; 153 | 154 | done(); 155 | }); 156 | }); 157 | 158 | it("should emit a 'backup' event", function(done) { 159 | db.emit("backup", {}) 160 | .then((result) => { 161 | // Result: void 162 | expect(result).to.not.exist; 163 | 164 | done(); 165 | }).catch(error => { 166 | expect(error).to.not.exist; 167 | 168 | done(); 169 | }); 170 | }); 171 | 172 | it("should emit a 'backups' event", function(done) { 173 | db.emit("backups", {}) 174 | .then((result) => { 175 | // Result: void 176 | expect(result).to.not.exist; 177 | 178 | done(); 179 | }).catch(error => { 180 | expect(error).to.not.exist; 181 | 182 | done(); 183 | }); 184 | }); 185 | 186 | it("should emit a 'removeBackup' event", function(done) { 187 | db.emit("removeBackup", {}) 188 | .then((result) => { 189 | // Result: void 190 | expect(result).to.not.exist; 191 | 192 | done(); 193 | }).catch(error => { 194 | expect(error).to.not.exist; 195 | 196 | done(); 197 | }); 198 | }); 199 | 200 | it("should emit a 'restore' event", function(done) { 201 | db.emit("restore", {}) 202 | .then((result) => { 203 | // Result: void 204 | expect(result).to.not.exist; 205 | 206 | done(); 207 | }).catch(error => { 208 | expect(error).to.not.exist; 209 | 210 | done(); 211 | }); 212 | }); 213 | }); 214 | }); -------------------------------------------------------------------------------- /test/unit/utils/ConnectionHelper.spec.ts: -------------------------------------------------------------------------------- 1 | import "mocha"; 2 | import { expect } from "chai"; 3 | 4 | import { TestHelper } from "../../helper/index"; 5 | import { ConnectionHelper } from "../../../src/utils/index"; 6 | import { MongoPortable } from "../../../src/core/index"; 7 | 8 | class MTestHelper extends TestHelper { 9 | constructor() { super(); } 10 | 11 | static createInstance() { 12 | return new MongoPortable("__test__", null); 13 | } 14 | } 15 | 16 | MTestHelper.initLogger(); 17 | 18 | describe("ConnectionHelper", function() { 19 | describe("- Constructor", function() { 20 | it("should have the dependencies ready", function() { 21 | MTestHelper.assertDependencies([ConnectionHelper, MongoPortable]); 22 | }); 23 | 24 | }); 25 | 26 | describe("- addConnection", function() { 27 | it("should add a connection", function() { 28 | let c = new ConnectionHelper(); 29 | 30 | expect(c.hasConnection("conn1")).to.be.false; 31 | 32 | c.addConnection("conn1", 1, MTestHelper.createInstance()); 33 | 34 | expect(c.hasConnection("conn1")).to.be.true; 35 | }); 36 | }); 37 | 38 | describe("- getConnection", function() { 39 | it("should get a collection", function() { 40 | let c = new ConnectionHelper(); 41 | 42 | c.addConnection("conn1", 1, MTestHelper.createInstance()); 43 | 44 | let conn = c.getConnection("conn0"); 45 | 46 | expect(conn).to.not.exist; 47 | 48 | conn = c.getConnection("conn1"); 49 | 50 | expect(conn).to.exist; 51 | 52 | expect(conn.name).to.be.equal("conn1"); 53 | }); 54 | }); 55 | 56 | describe("- dropConnection", function() { 57 | it("should not fail when deleting a non existing connection", function() { 58 | TestHelper.assertThrown(() => { 59 | let c = new ConnectionHelper(); 60 | 61 | c.dropConnection("conn1"); 62 | }, false); 63 | }); 64 | 65 | it("should delete a connection", function() { 66 | let c = new ConnectionHelper(); 67 | 68 | c.addConnection("conn1", 1, MTestHelper.createInstance()); 69 | 70 | expect(c.hasConnection("conn1")).to.be.true; 71 | 72 | c.dropConnection("conn1"); 73 | 74 | expect(c.hasConnection("conn1")).to.be.false; 75 | }); 76 | }); 77 | 78 | describe("- hasConnection", function() { 79 | it("should retrieve a connection", function() { 80 | let c = new ConnectionHelper(); 81 | 82 | c.addConnection("conn1", 1, MTestHelper.createInstance()); 83 | 84 | expect(c.hasConnection("conn0")).to.be.false; 85 | expect(c.hasConnection("conn1")).to.be.true; 86 | }); 87 | }); 88 | 89 | describe("- validateDatabaseName", function() { 90 | it("should fail if the 'name' param is not a string", function() { 91 | TestHelper.assertThrown(() => { 92 | let c = new ConnectionHelper(); 93 | 94 | c.validateDatabaseName(null); 95 | }, true); 96 | }); 97 | 98 | it("should fail if the 'name' param is an empty string", function() { 99 | TestHelper.assertThrown(() => { 100 | let c = new ConnectionHelper(); 101 | 102 | c.validateDatabaseName(""); 103 | }, true); 104 | }); 105 | 106 | it("should fail if the 'name' param contains invalid characters", function() { 107 | TestHelper.assertThrown(() => { 108 | let c = new ConnectionHelper(); 109 | 110 | c.validateDatabaseName("should fail"); 111 | }, true); 112 | 113 | TestHelper.assertThrown(() => { 114 | let c = new ConnectionHelper(); 115 | 116 | c.validateDatabaseName("should.fail"); 117 | }, true); 118 | 119 | TestHelper.assertThrown(() => { 120 | let c = new ConnectionHelper(); 121 | 122 | c.validateDatabaseName("should$fail"); 123 | }, true); 124 | 125 | TestHelper.assertThrown(() => { 126 | let c = new ConnectionHelper(); 127 | 128 | c.validateDatabaseName("should/fail"); 129 | }, true); 130 | 131 | /* TestHelper.assertThrown(() => { 132 | TestHelper.initLogger(true, false); 133 | 134 | let c = new ConnectionHelper(); 135 | 136 | expect(c.validateDatabaseName("should\fail")).to.be.false; 137 | 138 | TestHelper.initLogger(); 139 | }, false); */ 140 | }); 141 | 142 | it("should not fail if the 'name' param is a valid string", function() { 143 | TestHelper.assertThrown(() => { 144 | let c = new ConnectionHelper(); 145 | 146 | c.validateDatabaseName("should_not_fail"); 147 | }, false); 148 | 149 | TestHelper.assertThrown(() => { 150 | let c = new ConnectionHelper(); 151 | 152 | c.validateDatabaseName("should-not-fail"); 153 | }, false); 154 | }); 155 | }); 156 | 157 | }); -------------------------------------------------------------------------------- /test/unit/utils/Utils.spec.ts: -------------------------------------------------------------------------------- 1 | import "mocha"; 2 | import { expect } from "chai"; 3 | 4 | import { TestHelper } from "../../helper/index"; 5 | import { Utils } from "../../../src/utils/index"; 6 | 7 | TestHelper.initLogger(); 8 | 9 | describe("Utils", function() { 10 | describe("- Constructor", function() { 11 | it("should have the dependencies ready", function() { 12 | TestHelper.assertDependencies([Utils]); 13 | }); 14 | 15 | }); 16 | 17 | describe("- renameObjectProperty", function() { 18 | it("should not fail if no property is provided", function() { 19 | TestHelper.assertThrown(() => { 20 | let obj = { oldProp: "1" }; 21 | 22 | let newObj = Utils.renameObjectProperty(obj, null, null); 23 | 24 | expect(obj).to.be.deep.equal(newObj); 25 | }, false); 26 | }); 27 | 28 | it("should not fail if no new property is provided", function() { 29 | TestHelper.assertThrown(() => { 30 | let obj = { oldProp: "1" }; 31 | 32 | let newObj = Utils.renameObjectProperty(obj, "oldProp", null); 33 | 34 | expect(obj).to.be.deep.equal(newObj); 35 | }, false); 36 | }); 37 | 38 | it("should not fail if no different property is provided", function() { 39 | TestHelper.assertThrown(() => { 40 | let obj = { oldProp: "1" }; 41 | 42 | let newObj = Utils.renameObjectProperty(obj, "oldProp", "oldProp"); 43 | 44 | expect(obj).to.be.deep.equal(newObj); 45 | }, false); 46 | }); 47 | 48 | it("should work", function() { 49 | let obj = { oldProp: "1" }; 50 | 51 | let newObj = Utils.renameObjectProperty(obj, "oldProp", "newProp"); 52 | 53 | expect(obj).to.not.be.deep.equal(newObj); 54 | 55 | expect(newObj.oldProp).to.not.exist; 56 | expect(newObj.newProp).to.be.equal("1"); 57 | }); 58 | }); 59 | 60 | }); -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "sourceMap": true, 7 | "experimentalDecorators": true, 8 | "emitDecoratorMetadata": true, 9 | "lib": [ "es2015", "dom" ], 10 | "noImplicitAny": false, 11 | "suppressImplicitAnyIndexErrors": true, 12 | "baseUrl": ".", 13 | "downlevelIteration": true 14 | }, 15 | "exclude": [ 16 | "node_modules/", 17 | "test/" 18 | ] 19 | } --------------------------------------------------------------------------------