diff --git a/.bithoundrc b/.bithoundrc
index 9f021cd..5b50a56 100644
--- a/.bithoundrc
+++ b/.bithoundrc
@@ -13,16 +13,15 @@
},
"dependencies": {
"mute": [
- "tsdoc",
- "gulp-tsdoc",
- "istanbul",
- "semver",
- "gulp",
- "coveralls",
+ "chai",
+ "chai-as-promised",
+ "chalk",
"codeclimate-test-reporter",
- "del",
- "gulp-bump",
- "gulp-istanbul"
+ "concurrently",
+ "istanbul",
+ "mocha"
+ "tslint",
+ "typedoc"
]
}
}
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index 88c66cf..c4bf72a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,14 +1,4 @@
-Properties/
-bin/
-obj/
-*.suo
-*.user
-*.sublime*
-node_modules/
-.vs
-*.dat
-.idea
-*.tmp
+dist
+node_modules
coverage/
-.tscache
doc
\ No newline at end of file
diff --git a/.npmignore b/.npmignore
index d8b6019..5d19764 100644
--- a/.npmignore
+++ b/.npmignore
@@ -1,22 +1,8 @@
-.idea
-.vs
-.vscode
-benchmarks
-build
-coverage
-doc
-example
-obj
-test
-typings
-.bithoundrc
-.gitattributes
-.gitignore
-.gitmodules
-.jshintrc
-.travis.yml
-gulpfile.js
-Iridium.njsproj
-Iridium.sln
-Iridium.sublime-*
-tslint.json
\ No newline at end of file
+*
+!dist/**
+!package.json
+!LICENSE
+!CHANGELOG.md
+!CONTRIBUTING.md
+!README.md
+!tsconfig.json
\ No newline at end of file
diff --git a/Iridium.njsproj b/Iridium.njsproj
deleted file mode 100644
index e8711c9..0000000
--- a/Iridium.njsproj
+++ /dev/null
@@ -1,187 +0,0 @@
-
-
-
- Debug
- 2.0
- {e9a19872-d84f-418a-8332-3ded543fb1fa}
-
- ShowAllFiles
- node_modules\mocha\bin\mocha
- .
- .
- {3AF33F2E-1136-4D97-BBB7-1795711AC8B8};{349c5851-65df-11da-9384-00065b846f21};{9092AA53-FB77-4645-B42D-1CCCA6BD08BD}
- true
- CommonJS
- true
- 11.0
- $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
- C:\Program Files\iojs\iojs.exe
- False
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Code
- Mocha
-
-
- Code
- Mocha
-
-
- Code
- Mocha
-
-
- Code
- Mocha
-
-
- Mocha
-
-
- Code
- Mocha
-
-
- Mocha
-
-
- Code
- Mocha
-
-
- Mocha
-
-
-
- Mocha
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
-
-
-
- False
- True
- 0
- /
- http://localhost:48022/
- False
- True
- http://localhost:1337
- False
-
-
-
-
-
-
- CurrentPage
- True
- False
- False
- False
-
-
-
-
-
-
-
-
- False
- False
-
-
-
-
-
\ No newline at end of file
diff --git a/Iridium.sln b/Iridium.sln
deleted file mode 100644
index 3e496f8..0000000
--- a/Iridium.sln
+++ /dev/null
@@ -1,22 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 14
-VisualStudioVersion = 14.0.22609.0
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{9092AA53-FB77-4645-B42D-1CCCA6BD08BD}") = "Iridium", "Iridium.njsproj", "{E9A19872-D84F-418A-8332-3DED543FB1FA}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {E9A19872-D84F-418A-8332-3DED543FB1FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {E9A19872-D84F-418A-8332-3DED543FB1FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {E9A19872-D84F-418A-8332-3DED543FB1FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {E9A19872-D84F-418A-8332-3DED543FB1FA}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/benchmarks/mongodb.ts b/benchmarks/mongodb.ts
index 1faa12e..1b1c361 100644
--- a/benchmarks/mongodb.ts
+++ b/benchmarks/mongodb.ts
@@ -1,8 +1,8 @@
-import Iridium = require("../iridium");
-import Bluebird = require("bluebird");
-import MongoDB = require("mongodb");
-import _ = require("lodash");
-import crypto = require("crypto");
+import * as Iridium from "../iridium";
+import * as Bluebird from "bluebird";
+import * as MongoDB from "mongodb";
+import * as _ from "lodash";
+import * as crypto from "crypto";
var intensity = 1000;
var samples = 3;
@@ -38,7 +38,7 @@ class IridiumDB extends Iridium.Core {
console.log("Running benchmark with intensity of %d, %d samples", intensity, samples);
var results: { [name: string]: number } = {};
-function benchmark(name: string, prepare: (objects: UserDocument[]) => Bluebird, run: (objects: UserDocument[]) => Bluebird, compareTo?: string) {
+function benchmark(name: string, prepare: (objects: UserDocument[]) => Bluebird|null, run: (objects: UserDocument[]) => Bluebird, compareTo?: string) {
return Bluebird.resolve(new Array(samples)).map(() => {
var objects: UserDocument[] = new Array(intensity);
for (var i = 0; i < objects.length; i++)
@@ -80,7 +80,7 @@ iDB.connect()
return new Bluebird((resolve, reject) => {
iDB.connection.collection("mongodb").deleteMany({},(err) => {
if (err) return reject(err);
- return resolve(null);
+ return resolve({});
});
});
},(objects) => {
diff --git a/build/bundle.js b/build/bundle.js
deleted file mode 100644
index 3209811..0000000
--- a/build/bundle.js
+++ /dev/null
@@ -1,15 +0,0 @@
-"use strict";
-
-var typings = require('typings-core'),
- path = require('path'),
- chalk = require('chalk');
-
-typings.bundle({
- cwd: path.dirname(__dirname),
- out: path.resolve(__dirname, "../dist/main.d.ts")
-}).then(() => {
- console.log(chalk.green("bundled type definitions"));
-}, err => {
- console.error(chalk.red("failed to bundle type definitions"));
- console.error(chalk.gray(chalk.red("ERROR"), ": %s\n%s"), err.message, err.stack);
-});
\ No newline at end of file
diff --git a/circle.yml b/circle.yml
deleted file mode 100644
index ddd6ef1..0000000
--- a/circle.yml
+++ /dev/null
@@ -1,32 +0,0 @@
-general:
- branches:
- ignore:
- - gh-pages
- artifacts:
- - dist
-
-machine:
- node:
- version: 6
- environment:
- CI_SERVER: 1
-
-dependencies:
- override:
- - sudo apt-get purge mongodb-org*
- - sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
- - echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
- - sudo apt-get update
- - sudo apt-get install -y mongodb-org
- - sudo service mongod restart
- - npm install --progress=false
- - npm install mocha-junit-reporter --progress=false
-
-test:
- pre:
- - mongo --version
- - mongo --eval 'db.hostInfo()'
- override:
- - npm run test -- --reporter mocha-junit-reporter:
- environment:
- MOCHA_FILE: $CIRCLE_TEST_REPORTS/junit/test-results.xml
\ No newline at end of file
diff --git a/dist/.gitignore b/dist/.gitignore
deleted file mode 100644
index acdb84d..0000000
--- a/dist/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-benchmarks
-example
-test
-*.d.ts
-*.map
\ No newline at end of file
diff --git a/dist/.npmignore b/dist/.npmignore
deleted file mode 100644
index 82a5e6f..0000000
--- a/dist/.npmignore
+++ /dev/null
@@ -1,6 +0,0 @@
-benchmarks
-example
-lib/*.d.ts
-lib/*/**.d.ts
-browser.d.ts
-test
\ No newline at end of file
diff --git a/dist/index.js b/dist/index.js
deleted file mode 100644
index 050d14d..0000000
--- a/dist/index.js
+++ /dev/null
@@ -1,14 +0,0 @@
-"use strict";
-function __export(m) {
- for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
-}
-__export(require("./lib/Core"));
-__export(require("./lib/Model"));
-__export(require("./lib/Instance"));
-__export(require("./lib/Decorators"));
-__export(require("./lib/Transforms"));
-__export(require("./lib/caches/MemoryCache"));
-__export(require("./lib/caches/NoOpCache"));
-__export(require("./lib/cacheControllers/IDDirector"));
-__export(require("./lib/utils/ObjectID"));
-//# sourceMappingURL=index.js.map
\ No newline at end of file
diff --git a/dist/index.js.map b/dist/index.js.map
deleted file mode 100644
index 6890c05..0000000
--- a/dist/index.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;AAAA,iBAAc,YAAY,CAAC,EAAA;AAC3B,iBAAc,aAAa,CAAC,EAAA;AAC5B,iBAAc,gBAAgB,CAAC,EAAA;AAE/B,iBAAc,kBAAkB,CAAC,EAAA;AASjC,iBAAc,kBAAkB,CAAC,EAAA;AAEjC,iBAAc,0BAA0B,CAAC,EAAA;AACzC,iBAAc,wBAAwB,CAAC,EAAA;AAEvC,iBAAc,mCAAmC,CAAC,EAAA;AAElD,iBAAc,sBAAsB,CAAC,EAAA"}
\ No newline at end of file
diff --git a/dist/iridium.d.ts b/dist/iridium.d.ts
deleted file mode 100644
index 1c0ce3e..0000000
--- a/dist/iridium.d.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-export * from "./lib/Core";
-export * from "./lib/Model";
-export * from "./lib/Instance";
-export * from "./lib/Decorators";
-export * from "./lib/Plugins";
-export * from "./lib/Schema";
-export * from "./lib/Cache";
-export * from "./lib/CacheDirector";
-export * from "./lib/ModelOptions";
-export * from "./lib/Configuration";
-export * from "./lib/Hooks";
-export * from "./lib/Transforms";
-export * from "./lib/caches/MemoryCache";
-export * from "./lib/caches/NoOpCache";
-export * from "./lib/cacheControllers/IDDirector";
-export * from "./lib/utils/ObjectID";
diff --git a/dist/iridium.js b/dist/iridium.js
deleted file mode 100644
index eace17d..0000000
--- a/dist/iridium.js
+++ /dev/null
@@ -1,14 +0,0 @@
-"use strict";
-function __export(m) {
- for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
-}
-__export(require("./lib/Core"));
-__export(require("./lib/Model"));
-__export(require("./lib/Instance"));
-__export(require("./lib/Decorators"));
-__export(require("./lib/Transforms"));
-__export(require("./lib/caches/MemoryCache"));
-__export(require("./lib/caches/NoOpCache"));
-__export(require("./lib/cacheControllers/IDDirector"));
-__export(require("./lib/utils/ObjectID"));
-//# sourceMappingURL=iridium.js.map
\ No newline at end of file
diff --git a/dist/iridium.js.map b/dist/iridium.js.map
deleted file mode 100644
index 62af329..0000000
--- a/dist/iridium.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"iridium.js","sourceRoot":"","sources":["../iridium.ts"],"names":[],"mappings":";;;;AAAA,iBAAc,YAAY,CAAC,EAAA;AAC3B,iBAAc,aAAa,CAAC,EAAA;AAC5B,iBAAc,gBAAgB,CAAC,EAAA;AAE/B,iBAAc,kBAAkB,CAAC,EAAA;AASjC,iBAAc,kBAAkB,CAAC,EAAA;AAEjC,iBAAc,0BAA0B,CAAC,EAAA;AACzC,iBAAc,wBAAwB,CAAC,EAAA;AAEvC,iBAAc,mCAAmC,CAAC,EAAA;AAElD,iBAAc,sBAAsB,CAAC,EAAA"}
\ No newline at end of file
diff --git a/dist/lib/Aggregate.js b/dist/lib/Aggregate.js
deleted file mode 100644
index fb36ff5..0000000
--- a/dist/lib/Aggregate.js
+++ /dev/null
@@ -1,2 +0,0 @@
-"use strict";
-//# sourceMappingURL=Aggregate.js.map
\ No newline at end of file
diff --git a/dist/lib/Aggregate.js.map b/dist/lib/Aggregate.js.map
deleted file mode 100644
index e8ab70c..0000000
--- a/dist/lib/Aggregate.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"Aggregate.js","sourceRoot":"","sources":["../../lib/Aggregate.ts"],"names":[],"mappings":""}
\ No newline at end of file
diff --git a/dist/lib/BSON.js b/dist/lib/BSON.js
deleted file mode 100644
index 888ea9b..0000000
--- a/dist/lib/BSON.js
+++ /dev/null
@@ -1,5 +0,0 @@
-"use strict";
-var mongodb_1 = require("mongodb");
-exports.ObjectID = mongodb_1.ObjectID;
-exports.Binary = mongodb_1.Binary;
-//# sourceMappingURL=BSON.js.map
\ No newline at end of file
diff --git a/dist/lib/BSON.js.map b/dist/lib/BSON.js.map
deleted file mode 100644
index 0a05db8..0000000
--- a/dist/lib/BSON.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"BSON.js","sourceRoot":"","sources":["../../lib/BSON.ts"],"names":[],"mappings":";AAAA,wBAAiC,SAAS,CAAC;AAAlC,sCAAQ;AAAE,kCAAwB"}
\ No newline at end of file
diff --git a/dist/lib/Cache.js b/dist/lib/Cache.js
deleted file mode 100644
index e36eaeb..0000000
--- a/dist/lib/Cache.js
+++ /dev/null
@@ -1,2 +0,0 @@
-"use strict";
-//# sourceMappingURL=Cache.js.map
\ No newline at end of file
diff --git a/dist/lib/Cache.js.map b/dist/lib/Cache.js.map
deleted file mode 100644
index a7f5bfe..0000000
--- a/dist/lib/Cache.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"Cache.js","sourceRoot":"","sources":["../../lib/Cache.ts"],"names":[],"mappings":""}
\ No newline at end of file
diff --git a/dist/lib/CacheDirector.js b/dist/lib/CacheDirector.js
deleted file mode 100644
index 37a2cf2..0000000
--- a/dist/lib/CacheDirector.js
+++ /dev/null
@@ -1,2 +0,0 @@
-"use strict";
-//# sourceMappingURL=CacheDirector.js.map
\ No newline at end of file
diff --git a/dist/lib/CacheDirector.js.map b/dist/lib/CacheDirector.js.map
deleted file mode 100644
index 449cadb..0000000
--- a/dist/lib/CacheDirector.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"CacheDirector.js","sourceRoot":"","sources":["../../lib/CacheDirector.ts"],"names":[],"mappings":""}
\ No newline at end of file
diff --git a/dist/lib/Configuration.js b/dist/lib/Configuration.js
deleted file mode 100644
index e382fd7..0000000
--- a/dist/lib/Configuration.js
+++ /dev/null
@@ -1,2 +0,0 @@
-"use strict";
-//# sourceMappingURL=Configuration.js.map
\ No newline at end of file
diff --git a/dist/lib/Configuration.js.map b/dist/lib/Configuration.js.map
deleted file mode 100644
index 0865480..0000000
--- a/dist/lib/Configuration.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"Configuration.js","sourceRoot":"","sources":["../../lib/Configuration.ts"],"names":[],"mappings":""}
\ No newline at end of file
diff --git a/dist/lib/Core.js b/dist/lib/Core.js
deleted file mode 100644
index b20811c..0000000
--- a/dist/lib/Core.js
+++ /dev/null
@@ -1,188 +0,0 @@
-"use strict";
-const Bluebird = require("bluebird");
-const MongoDB = require("mongodb");
-const _ = require("lodash");
-const Express_1 = require("./middleware/Express");
-const NoOpCache_1 = require("./caches/NoOpCache");
-/**
- * The Iridium Core, responsible for managing the connection to the database as well
- * as any plugins you are making use of.
- *
- * Generally you will subclass this to provide your own custom core with the models you
- * make use of within your application.
- */
-class Core {
- constructor(uri, config) {
- this.mongoConnectAsyc = Bluebird.promisify(MongoDB.MongoClient.connect);
- this._plugins = [];
- this._cache = new NoOpCache_1.NoOpCache();
- let args = Array.prototype.slice.call(arguments, 0);
- uri = config = null;
- for (let i = 0; i < args.length; i++) {
- if (typeof args[i] == "string")
- uri = args[i];
- else if (typeof args[i] == "object")
- config = args[i];
- }
- if (!uri && !config)
- throw new Error("Expected either a URI or config object to be supplied when initializing Iridium");
- this._url = uri;
- this._config = config;
- }
- /**
- * Gets the plugins registered with this Iridium Core
- * @returns {[Iridium.Plugin]}
- */
- get plugins() {
- return this._plugins;
- }
- /**
- * Gets the configuration specified in the construction of this
- * Iridium Core.
- * @returns {Iridium.Configuration}
- */
- get settings() {
- return this._config;
- }
- /**
- * Gets the currently active database connection for this Iridium
- * Core.
- * @returns {MongoDB.Db}
- */
- get connection() {
- return this._connection;
- }
- /**
- * Gets the URL used to connect to MongoDB
- * @returns {String}
- */
- get url() {
- if (this._url)
- return this._url;
- let url = "mongodb://";
- if (this._config.username) {
- url += this._config.username;
- if (this._config.password)
- url += ":" + this._config.password;
- url += "@";
- }
- let hosts = [];
- if (this._config.host) {
- if (this._config.port)
- hosts.push(this._config.host + ":" + this._config.port);
- else
- hosts.push(this._config.host);
- }
- if (this._config.hosts) {
- _.each(this._config.hosts, (host) => {
- if (host.port)
- hosts.push(host.address + ":" + host.port);
- else if (this._config.port)
- hosts.push(host.address + ":" + this._config.port);
- else
- hosts.push(host.address);
- });
- }
- if (hosts.length)
- url += _.uniq(hosts).join(",");
- else
- url += "localhost";
- url += "/" + this._config.database;
- return url;
- }
- /**
- * Gets the cache used to store objects retrieved from the database for performance reasons
- * @returns {cache}
- */
- get cache() {
- return this._cache;
- }
- set cache(value) {
- this._cache = value;
- }
- /**
- * Registers a new plugin with this Iridium Core
- * @param {Iridium.Plugin} plugin The plugin to register with this Iridium Core
- * @returns {Iridium.Core}
- */
- register(plugin) {
- this.plugins.push(plugin);
- return this;
- }
- /**
- * Connects to the database server specified in the provided configuration
- * @param {function(Error, Iridium.Core)} [callback] A callback to be triggered once the connection is established.
- * @returns {Promise}
- */
- connect(callback) {
- return Bluebird.resolve().then(() => {
- if (this._connection)
- return this._connection;
- if (this._connectPromise)
- return this._connectPromise;
- return this._connectPromise = this.mongoConnectAsyc(this.url, this._config && this._config.options);
- }).then((db) => {
- return this.onConnecting(db);
- }).then(db => {
- this._connection = db;
- this._connectPromise = null;
- return this.onConnected();
- }).then(() => {
- return this;
- }, (err) => {
- if (this._connection)
- this._connection.close();
- this._connection = null;
- this._connectPromise = null;
- return Bluebird.reject(err);
- }).nodeify(callback);
- }
- /**
- * Closes the active database connection
- * @type {Promise}
- */
- close() {
- return Bluebird.resolve().then(() => {
- if (!this._connection)
- return this;
- let conn = this._connection;
- this._connection = null;
- conn.close();
- return this;
- });
- }
- /**
- * Provides an express middleware which can be used to set the req.db property
- * to the current Iridium instance.
- * @returns {Iridium.ExpressMiddleware}
- */
- express() {
- return Express_1.ExpressMiddlewareFactory(this);
- }
- /**
- * A method which is called whenever a new connection is made to the database.
- *
- * @param connection The underlying MongoDB connection which was created, you can modify or replace this if you wish.
- * @returns A promise for the connection, allowing you to perform any asynchronous initialization required by your application.
- *
- * In subclassed Iridium Cores this method can be overridden to manipulate the properties
- * of the underlying MongoDB connection object, such as authenticating. Until this method
- * resolves a connection object, Iridium will be unable to execute any queries. If you wish
- * to run Iridium queries then look at the onConnected method.
- */
- onConnecting(connection) {
- return Bluebird.resolve(connection);
- }
- /**
- * A method which is called once a database connection has been established and accepted by Iridium
- *
- * In subclassed Iridium cores this method can be overridden to perform tasks whenever a
- * connection to the database has been established - such as setting up indexes for your
- * collections or seeding the database.
- */
- onConnected() {
- return Bluebird.resolve();
- }
-}
-exports.Core = Core;
-//# sourceMappingURL=Core.js.map
\ No newline at end of file
diff --git a/dist/lib/Core.js.map b/dist/lib/Core.js.map
deleted file mode 100644
index c312a44..0000000
--- a/dist/lib/Core.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"Core.js","sourceRoot":"","sources":["../../lib/Core.ts"],"names":[],"mappings":";AAAA,MAAY,QAAQ,WAAM,UAAU,CAAC,CAAA;AACrC,MAAY,OAAO,WAAM,SAAS,CAAC,CAAA;AACnC,MAAY,CAAC,WAAM,QAAQ,CAAC,CAAA;AAW5B,0BAAuC,sBAAsB,CAAC,CAAA;AAG9D,4BAAwB,oBAAoB,CAAC,CAAA;AAG7C;;;;;;GAMG;AACH;IAcI,YAAY,GAA2B,EAAE,MAAsB;QAiBvD,qBAAgB,GAAG,QAAQ,CAAC,SAAS,CAA0B,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QAE5F,aAAQ,GAAa,EAAE,CAAC;QAIxB,WAAM,GAAU,IAAI,qBAAS,EAAE,CAAC;QArBpC,IAAI,IAAI,GAAG,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;QACpD,GAAG,GAAG,MAAM,GAAG,IAAI,CAAC;QACpB,GAAG,CAAC,CAAC,IAAI,CAA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CAAC,WAAW,CAAC;gBAAC,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;YAC/C,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;YACxB,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;YAC5B,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAChC,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACzB,CAAC;IAED;;;OAGG;IACH,KAAK;QACD,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC;YAC3B,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC;gBAAC,MAAM,CAAC,IAAI,CAAC;YACnC,IAAI,IAAI,GAAe,IAAI,CAAC,WAAW,CAAC;YACxC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;YACxB,IAAI,CAAC,KAAK,EAAE,CAAC;YACb,MAAM,CAAC,IAAI,CAAC;QAChB,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;;;OAIG;IACH,OAAO;QACH,MAAM,CAAC,kCAAwB,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED;;;;;;;;;;OAUG;IACO,YAAY,CAAC,UAAsB;QACzC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACxC,CAAC;IAED;;;;;;OAMG;IACO,WAAW;QACjB,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;IAC9B,CAAC;AACL,CAAC;AAhNY,YAAI,OAgNhB,CAAA"}
\ No newline at end of file
diff --git a/dist/lib/Cursor.js b/dist/lib/Cursor.js
deleted file mode 100644
index 06e84c6..0000000
--- a/dist/lib/Cursor.js
+++ /dev/null
@@ -1,179 +0,0 @@
-"use strict";
-const Bluebird = require("bluebird");
-/**
- * An Iridium collection cursor which allows the itteration through documents
- * in the collection, automatically wrapping them in the correct instance type.
- *
- * @param TDocument The interface representing the collection's documents
- * @param TInstance The interface or class used to represent the wrapped documents.
- */
-class Cursor {
- /**
- * Creates a new Iridium cursor which wraps a MongoDB cursor object
- * @param {Model} model The Iridium model that this cursor belongs to
- * @param {Object} conditions The conditions that resulte in this cursor being created
- * @param {MongoDB.Cursor} cursor The MongoDB native cursor object to be wrapped
- * @constructor
- */
- constructor(model, conditions, cursor) {
- this.model = model;
- this.conditions = conditions;
- this.cursor = cursor;
- }
- /**
- * Counts the number of documents which are matched by this cursor
- * @param {function(Error, Number)} callback A callback which is triggered when the result is available
- * @return {Promise} A promise which will resolve with the number of documents matched by this cursor
- */
- count(callback) {
- return new Bluebird((resolve, reject) => {
- this.cursor.count(true, (err, count) => {
- if (err)
- return reject(err);
- return resolve(count);
- });
- }).nodeify(callback);
- }
- /**
- * Runs the specified handler over each instance in the query results
- * @param {function(Instance)} handler The handler which is triggered for each element in the query
- * @param {function(Error)} callback A callback which is triggered when all operations have been dispatched
- * @return {Promise} A promise which is resolved when all operations have been dispatched
- */
- forEach(handler, callback) {
- let helpers = this.model.helpers;
- return new Bluebird((resolve, reject) => {
- this.cursor.forEach((item) => {
- this.model.handlers.documentReceived(this.conditions, item, function () { return helpers.wrapDocument.apply(helpers, arguments); }).then(handler);
- }, (err) => {
- if (err)
- return reject(err);
- return resolve(null);
- });
- }).nodeify(callback);
- }
- /**
- * Runs the specified transform over each instance in the query results and returns the resulting transformed objects
- * @param {function(Instance): TResult} transform A handler which is used to transform the result objects
- * @param {function(Error, TResult[])} callback A callback which is triggered when the transformations are completed
- * @return {Promise} A promise which is fulfilled with the results of the transformations
- */
- map(transform, callback) {
- let helpers = this.model.helpers;
- return new Bluebird((resolve, reject) => {
- let promises = [];
- this.cursor.forEach((item) => {
- promises.push(this.model.handlers.documentReceived(this.conditions, item, function () { return helpers.wrapDocument.apply(helpers, arguments); })
- .then(transform));
- }, (err) => {
- if (err)
- return reject(err);
- return resolve(Bluebird.all(promises));
- });
- }).nodeify(callback);
- }
- /**
- * Retrieves all matching instances and returns them in an array
- * @param {function(Error, TInstance[])} callback A callback which is triggered with the resulting instances
- * @return {Promise} A promise which resolves with the instances returned by the query
- */
- toArray(callback) {
- let helpers = this.model.helpers;
- return new Bluebird((resolve, reject) => {
- this.cursor.toArray((err, results) => {
- if (err)
- return reject(err);
- return resolve(results);
- });
- }).map((document) => {
- return this.model.handlers.documentReceived(this.conditions, document, function () { return helpers.wrapDocument.apply(helpers, arguments); });
- }).nodeify(callback);
- }
- /**
- * Retrieves the next item in the results list
- * @param {function(Error, TInstance)} callback A callback which is triggered when the next item becomes available
- * @return {Promise} A promise which is resolved with the next item
- */
- next(callback) {
- return new Bluebird((resolve, reject) => {
- this.cursor.next((err, result) => {
- if (err)
- return reject(err);
- return resolve(result);
- });
- }).then((document) => {
- if (!document)
- return Bluebird.resolve(null);
- return this.model.handlers.documentReceived(this.conditions, document, (document, isNew, isPartial) => this.model.helpers.wrapDocument(document, isNew, isPartial));
- }).nodeify(callback);
- }
- /**
- * Retrieves the next item in the result list and then closes the cursor
- * @param {function(Error, TInstance)} callback A callback which is triggered when the next item becomes available
- * @return {Promise} A promise which is resolved once the item becomes available and the cursor has been closed.
- */
- one(callback) {
- return new Bluebird((resolve, reject) => {
- this.cursor.next((err, result) => {
- if (err)
- return reject(err);
- return resolve(result);
- });
- }).then((document) => {
- return new Bluebird((resolve, reject) => {
- this.cursor.close((err) => {
- if (err)
- return reject(err);
- return resolve(document);
- });
- });
- }).then((document) => {
- if (!document)
- return Bluebird.resolve(null);
- return this.model.handlers.documentReceived(this.conditions, document, (document, isNew, isPartial) => this.model.helpers.wrapDocument(document, isNew, isPartial));
- }).nodeify(callback);
- }
- /**
- * Returns a new cursor which behaves the same as this one did before any results were retrieved
- * @return {Cursor} The new cursor which starts at the beginning of the results
- */
- rewind() {
- this.cursor.rewind();
- return this;
- }
- /**
- * Returns a new cursor which sorts its results by the given index expression
- * @param {model.IndexSpecification} sortExpression The index expression dictating the sort order and direction to use
- * @return {Cursor} The new cursor which sorts its results by the sortExpression
- */
- sort(sortExpression) {
- return new Cursor(this.model, this.conditions, this.cursor.sort(sortExpression));
- }
- /**
- * Returns a new cursor which limits the number of returned results
- * @param {Number} limit The maximum number of results to return
- * @return {Cursor} The new cursor which will return a maximum number of results
- */
- limit(limit) {
- return new Cursor(this.model, this.conditions, this.cursor.limit(limit));
- }
- /**
- * Returns a new cursor which skips a number of results before it begins
- * returning any.
- * @param {Number} skip The number of results to skip before the cursor beings returning
- * @return {Cursor} The new cursor which skips a number of results
- */
- skip(skip) {
- return new Cursor(this.model, this.conditions, this.cursor.skip(skip));
- }
- /**
- * Returns a new cursor which will read from the specified node type.
- * @param {String} type The type of node to read from - see https://docs.mongodb.org/manual/core/read-preference/
- * @return {Cursor} The new cursor which reads from the specified node type
- */
- readFrom(type) {
- return new Cursor(this.model, this.conditions, this.cursor.setReadPreference(type));
- }
-}
-exports.Cursor = Cursor;
-//# sourceMappingURL=Cursor.js.map
\ No newline at end of file
diff --git a/dist/lib/Cursor.js.map b/dist/lib/Cursor.js.map
deleted file mode 100644
index f85f39e..0000000
--- a/dist/lib/Cursor.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"Cursor.js","sourceRoot":"","sources":["../../lib/Cursor.ts"],"names":[],"mappings":";AAGA,MAAY,QAAQ,WAAM,UAAU,CAAC,CAAA;AAGrC;;;;;;GAMG;AACH;IACI;;;;;;OAMG;IACH,YAAoB,KAAkC,EAAU,UAAe,EAAS,MAAsB;QAA1F,UAAK,GAAL,KAAK,CAA6B;QAAU,eAAU,GAAV,UAAU,CAAK;QAAS,WAAM,GAAN,MAAM,CAAgB;IAE9G,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,QAAmC;QACrC,MAAM,CAAC,IAAI,QAAQ,CAAS,CAAC,OAAO,EAAE,MAAM;YACxC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,KAAK;gBAC/B,EAAE,CAAC,CAAC,GAAG,CAAC;oBAAC,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AAI,CAAC,IAAY;QACb,MAAM,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3E,CAAC;IAED;;;;OAIG;IACH,QAAQ,CAAC,IAAY;QACjB,MAAM,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC;IACxF,CAAC;AACL,CAAC;AAvKY,cAAM,SAuKlB,CAAA"}
\ No newline at end of file
diff --git a/dist/lib/Decorators.js b/dist/lib/Decorators.js
deleted file mode 100644
index a0e39c3..0000000
--- a/dist/lib/Decorators.js
+++ /dev/null
@@ -1,125 +0,0 @@
-"use strict";
-const MongoDB = require("mongodb");
-const _ = require("lodash");
-const Skmatc = require("skmatc");
-const Transforms_1 = require("./Transforms");
-/**
- * Specifies the name of the collection to which this instance's documents should be sent.
- * @param name The name of the MongoDB collection to store the documents in.
- *
- * This decorator replaces the use of the static collection property on instance implementation
- * classes. If your transpiler does not support decorators then you are free to make use of the
- * property instead.
- */
-function Collection(name) {
- return function (target) {
- target.collection = name;
- };
-}
-exports.Collection = Collection;
-/**
- * Specifies a MongoDB collection level index to be managed by Iridium for this instance type.
- * More than one instance of this decorator may be used if you wish to specify multiple indexes.
- * @param spec The formal index specification which defines the properties and ordering used in the index.
- * @param options The options dictating the way in which the index behaves.
- *
- * This decorator replaces the use of the static indexes property on instance implementation
- * classes. If your transpiler does not support decorators then you are free to make use of the
- * property instead.
- */
-function Index(spec, options) {
- return function (target) {
- target.indexes = (target.indexes || []).concat({ spec: spec, options: options || {} });
- };
-}
-exports.Index = Index;
-/**
- * Specifies a custom validator to be made available for this collection's schema.
- * More than one instance of this decorator may be used if you wish to specify multiple validators.
- * @param forType The value in the schema which will be delegated to this function for validation.
- * @param validate A function which calls this.assert(condition) to determine whether a schema node is valid or not.
- *
- * This decorator replaces the use of the static validators property on instance implementation
- * classes. If your transpiler does not support decorators then you are free to make use of the
- * property instead.
- */
-function Validate(forType, validate) {
- return function (target) {
- target.validators = (target.validators || []).concat(Skmatc.create(schema => schema === forType, validate));
- };
-}
-exports.Validate = Validate;
-function Property(...args) {
- let name = null, asType = false, required = true;
- if (args.length > 1 && typeof args[args.length - 1] === "boolean")
- required = args.pop();
- return function (target, property) {
- let staticTarget = target;
- if (!property)
- name = args.shift();
- else {
- name = property;
- staticTarget = target.constructor;
- }
- asType = args.pop() || false;
- staticTarget.schema = _.clone(staticTarget.schema || { _id: false });
- if (!required && typeof asType !== "boolean")
- staticTarget.schema[name] = { $required: required, $type: asType };
- else
- staticTarget.schema[name] = asType;
- };
-}
-exports.Property = Property;
-/**
- * Specifies a custom transform to be applied to the property this decorator is applied to.
- *
- * @param fromDB The function used to convert values from the database for the application.
- * @param toDB The function used to convert values from the application to the form used in the database.
- *
- * This decorator can either compliment or replace the static transforms property on your instance
- * class, however only one transform can be applied to any property at a time.
- * If your transpiler does not support decorators then you are free to make use of the
- * property instead.
- *
- * If this decorator is applied to the instance class itself, as opposed to a property, then
- * it will be treated as a $document transformer - and will receive the full document as opposed
- * to individual property values. Similarly, it is expected to return a full document when either
- * fromDB or toDB is called.
- */
-function Transform(fromDB, toDB) {
- return function (target, property = "$document") {
- let staticTarget = (target.constructor || target);
- staticTarget.transforms = _.clone(staticTarget.transforms || {});
- staticTarget.transforms[property] = {
- fromDB: fromDB,
- toDB: toDB
- };
- };
-}
-exports.Transform = Transform;
-/**
- * Specifies that this property should be treated as an ObjectID, with the requisite validator and transforms.
- *
- * This decorator applies an ObjectID validator to the property, which ensures that values sent to the database
- * are instances of the MongoDB ObjectID type, as well as applying a transform operation which converts ObjectIDs
- * to strings for your application, and then converts strings back to ObjectIDs for the database.
- */
-function ObjectID(target, name) {
- Property(MongoDB.ObjectID)(target, name);
- Transform(Transforms_1.DefaultTransforms.ObjectID.fromDB, Transforms_1.DefaultTransforms.ObjectID.toDB)(target, name);
-}
-exports.ObjectID = ObjectID;
-/**
- * Specifies that this property should be stored using the MongoDB binary type and represented as a Buffer.
- *
- * This decorator applies a Buffer validator to the property, which ensures that values you send to the database
- * are well formatted Buffer objects represented using the BSON Binary datatype. In addition to this, it will
- * apply a transform which ensures you only work with Buffer objects and that data is always stored in Binary
- * format.
- */
-function Binary(target, name) {
- Property(Buffer)(target, name);
- Transform(Transforms_1.DefaultTransforms.Binary.fromDB, Transforms_1.DefaultTransforms.Binary.toDB)(target, name);
-}
-exports.Binary = Binary;
-//# sourceMappingURL=Decorators.js.map
\ No newline at end of file
diff --git a/dist/lib/Decorators.js.map b/dist/lib/Decorators.js.map
deleted file mode 100644
index e6dc2cc..0000000
--- a/dist/lib/Decorators.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"Decorators.js","sourceRoot":"","sources":["../../lib/Decorators.ts"],"names":[],"mappings":";AAAA,MAAY,OAAO,WAAM,SAAS,CAAC,CAAA;AACnC,MAAY,CAAC,WAAM,QAAQ,CAAC,CAAA;AAC5B,MAAY,MAAM,WAAM,QAAQ,CAAC,CAAA;AAMjC,6BAA4C,cAAc,CAAC,CAAA;AAE3D;;;;;;;GAOG;AACH,oBAA2B,IAAY;IACtC,MAAM,CAAC,UAAS,MAAwC;QACvD,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC;IAC1B,CAAC,CAAC;AACH,CAAC;AAJe,kBAAU,aAIzB,CAAA;AAED;;;;;;;;;GASG;AACH,eAAsB,IAAwB,EAAE,OAA8B;IAC7E,MAAM,CAAC,UAAS,MAAuC;QACtD,MAAM,CAAC,OAAO,GAAG,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,MAAM,CAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,CAAC,CAAC;IAC/F,CAAC,CAAA;AACF,CAAC;AA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line at end of file
diff --git a/dist/lib/General.js b/dist/lib/General.js
deleted file mode 100644
index 0b2164e..0000000
--- a/dist/lib/General.js
+++ /dev/null
@@ -1,2 +0,0 @@
-"use strict";
-//# sourceMappingURL=General.js.map
\ No newline at end of file
diff --git a/dist/lib/General.js.map b/dist/lib/General.js.map
deleted file mode 100644
index 5b3f975..0000000
--- a/dist/lib/General.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"General.js","sourceRoot":"","sources":["../../lib/General.ts"],"names":[],"mappings":""}
\ No newline at end of file
diff --git a/dist/lib/Hooks.js b/dist/lib/Hooks.js
deleted file mode 100644
index 42f41b7..0000000
--- a/dist/lib/Hooks.js
+++ /dev/null
@@ -1,2 +0,0 @@
-"use strict";
-//# sourceMappingURL=Hooks.js.map
\ No newline at end of file
diff --git a/dist/lib/Hooks.js.map b/dist/lib/Hooks.js.map
deleted file mode 100644
index 5b77db3..0000000
--- a/dist/lib/Hooks.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"Hooks.js","sourceRoot":"","sources":["../../lib/Hooks.ts"],"names":[],"mappings":""}
\ No newline at end of file
diff --git a/dist/lib/Index.js b/dist/lib/Index.js
deleted file mode 100644
index 3a3a9b2..0000000
--- a/dist/lib/Index.js
+++ /dev/null
@@ -1,2 +0,0 @@
-"use strict";
-//# sourceMappingURL=Index.js.map
\ No newline at end of file
diff --git a/dist/lib/Index.js.map b/dist/lib/Index.js.map
deleted file mode 100644
index 5c062a6..0000000
--- a/dist/lib/Index.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"Index.js","sourceRoot":"","sources":["../../lib/Index.ts"],"names":[],"mappings":""}
\ No newline at end of file
diff --git a/dist/lib/Instance.js b/dist/lib/Instance.js
deleted file mode 100644
index 75cbf57..0000000
--- a/dist/lib/Instance.js
+++ /dev/null
@@ -1,262 +0,0 @@
-"use strict";
-const Validators_1 = require("./Validators");
-const _ = require("lodash");
-const Bluebird = require("bluebird");
-/**
- * The default Iridium Instance implementation which provides methods for saving, refreshing and
- * removing the wrapped document from the collection, as well as integrating with Omnom, our
- * built in document diff processor which allows clean, atomic, document updates to be performed
- * without needing to write the update queries yourself.
- *
- * @param TDocument The interface representing the structure of the documents in the collection.
- * @param TInstance The type of instance which wraps the documents, generally the subclass of this class.
- *
- * This class will be subclassed automatically by Iridium to create a model specific instance
- * which takes advantage of some of v8's optimizations to boost performance significantly.
- * The instance returned by the model, and all of this instance's methods, will be of type
- * TInstance - which should represent the merger of TSchema and IInstance for best results.
- */
-class Instance {
- /**
- * Creates a new instance which represents the given document as a type of model
- * @param model The model that dictates the collection the document originated from as well as how validations are performed.
- * @param document The document which should be wrapped by this instance
- * @param isNew Whether the document is new (doesn't exist in the database) or not
- * @param isPartial Whether the document has only a subset of its fields populated
- *
- */
- constructor(model, document, isNew = true, isPartial = false) {
- this._model = model;
- this._isNew = !!isNew;
- this._isPartial = isPartial;
- this._original = document;
- this._modified = model.helpers.cloneDocument(document);
- _.each(model.core.plugins, (plugin) => {
- if (plugin.newInstance)
- plugin.newInstance(this, model);
- });
- }
- /**
- * Gets the underlying document representation of this instance
- */
- get document() {
- return this._modified;
- }
- save(...args) {
- let callback = null;
- let changes = null;
- let conditions = {};
- Array.prototype.slice.call(args, 0).reverse().forEach((arg) => {
- if (typeof arg == "function")
- callback = arg;
- else if (typeof arg == "object") {
- if (!changes)
- changes = arg;
- else
- conditions = arg;
- }
- });
- return Bluebird.resolve().then(() => {
- conditions = this._model.helpers.cloneConditions(conditions);
- _.merge(conditions, { _id: this._modified._id });
- if (!changes) {
- let validation = this._model.helpers.validate(this._modified);
- if (validation.failed)
- return Bluebird.reject(validation.error).bind(this).nodeify(callback);
- let original = this._model.helpers.cloneDocument(this._original);
- let modified = this._model.helpers.cloneDocument(this._modified);
- modified = this._model.helpers.transformToDB(modified, { document: true });
- changes = this._model.helpers.diff(original, modified);
- }
- if (!_.keys(changes).length)
- return null;
- return changes;
- }).then((changes) => {
- if (!changes && !this._isNew)
- return changes;
- return this._model.handlers.savingDocument(this, changes).then(() => changes);
- }).then((changes) => {
- if (!changes && !this._isNew)
- return false;
- if (this._isNew) {
- return new Bluebird((resolve, reject) => {
- this._model.collection.insertOne(this._modified, { w: "majority" }, (err, doc) => {
- if (err)
- return reject(err);
- return resolve(!!doc);
- });
- });
- }
- else {
- return new Bluebird((resolve, reject) => {
- this._model.collection.updateOne(conditions, changes, { w: "majority" }, (err, changed) => {
- if (err) {
- err["conditions"] = conditions;
- err["changes"] = changes;
- return reject(err);
- }
- return resolve(!!changed.modifiedCount);
- });
- });
- }
- }).catch(err => {
- err["original"] = this._original;
- err["modified"] = this._modified;
- return Bluebird.reject(err);
- }).then((changed) => {
- conditions = { _id: this._modified._id };
- if (!changed)
- return this._modified;
- return new Bluebird((resolve, reject) => {
- this._model.collection.find(conditions).limit(1).next((err, latest) => {
- if (err)
- return reject(err);
- return resolve(latest);
- });
- });
- }).then((latest) => {
- if (!latest) {
- this._isNew = true;
- this._original = this._model.helpers.cloneDocument(this._modified);
- return Bluebird.resolve(this);
- }
- return this._model.handlers.documentReceived(conditions, latest, (value) => {
- this._isPartial = false;
- this._isNew = false;
- this._modified = value;
- this._original = this._model.helpers.cloneDocument(value);
- return this;
- });
- }).nodeify(callback);
- }
- /**
- * Updates this instance to match the latest document available in the backing collection
- * @param {function(Error, IInstance)} callback A callback which is triggered when the update completes
- * @returns {Promise}
- */
- update(callback) {
- return this.refresh(callback);
- }
- /**
- * Updates this instance to match the latest document available in the backing collection
- * @param {function(Error, IInstance)} callback A callback which is triggered when the update completes
- * @returns {Promise}
- */
- refresh(callback) {
- let conditions = { _id: this._original._id };
- return Bluebird.resolve().then(() => {
- return new Bluebird((resolve, reject) => {
- this._model.collection.find(conditions).limit(1).next((err, doc) => {
- if (err)
- return reject(err);
- return resolve(doc);
- });
- });
- }).then((newDocument) => {
- if (!newDocument) {
- this._isPartial = true;
- this._isNew = true;
- this._original = this._model.helpers.cloneDocument(this._modified);
- return this;
- }
- return this._model.handlers.documentReceived(conditions, newDocument, (doc) => {
- this._isNew = false;
- this._isPartial = false;
- this._original = doc;
- this._modified = this._model.helpers.cloneDocument(doc);
- return this;
- });
- }).nodeify(callback);
- }
- /**
- * Removes this instance's document from the backing collection
- * @param {function(Error, IInstance)} callback A callback which is triggered when the operation completes
- * @returns {Promise}
- */
- delete(callback) {
- return this.remove(callback);
- }
- /**
- * Removes this instance's document from the backing collection
- * @param {function(Error, IInstance)} callback A callback which is triggered when the operation completes
- * @returns {Promise}
- */
- remove(callback) {
- let conditions = { _id: this._original._id };
- return Bluebird.resolve().then(() => {
- if (this._isNew)
- return 0;
- return new Bluebird((resolve, reject) => {
- this._model.collection.deleteOne(conditions, { w: "majority" }, (err, removed) => {
- if (err)
- return reject(err);
- return resolve(removed);
- });
- });
- }).then((removed) => {
- if (removed)
- return this._model.cache.clear(conditions);
- return false;
- }).then(() => {
- this._isNew = true;
- return this;
- }).nodeify(callback);
- }
- first(collection, predicate) {
- let result = null;
- _.each(collection, (value, key) => {
- if (predicate.call(this, value, key)) {
- result = value;
- return false;
- }
- });
- return result;
- }
- select(collection, predicate) {
- let isArray = Array.isArray(collection);
- let results = isArray ? [] : {};
- _.each(collection, (value, key) => {
- if (predicate.call(this, value, key)) {
- if (isArray)
- results.push(value);
- else
- results[key] = value;
- }
- });
- return results;
- }
- /**
- * Gets the JSON representation of this instance
- * @returns {TDocument}
- */
- toJSON() {
- return this.document;
- }
- /**
- * Gets a string representation of this instance
- * @returns {String}
- */
- toString() {
- return JSON.stringify(this.document, null, 2);
- }
-}
-/**
- * The schema used to validate documents of this type before being stored in the database.
- */
-Instance.schema = {
- _id: false
-};
-/**
- * Additional which should be made available for use in the schema definition for this instance.
- */
-Instance.validators = Validators_1.DefaultValidators();
-/**
- * The transformations which should be applied to properties of documents of this type.
- */
-Instance.transforms = {};
-/**
- * The indexes which should be managed by Iridium for the collection used by this type.
- */
-Instance.indexes = [];
-exports.Instance = Instance;
-//# sourceMappingURL=Instance.js.map
\ No newline at end of file
diff --git a/dist/lib/Instance.js.map b/dist/lib/Instance.js.map
deleted file mode 100644
index c953f16..0000000
--- a/dist/lib/Instance.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"Instance.js","sourceRoot":"","sources":["../../lib/Instance.ts"],"names":[],"mappings":";AASA,6BAAgC,cAAc,CAAC,CAAA;AAE/C,MAAY,CAAC,WAAM,QAAQ,CAAC,CAAA;AAE5B,MAAY,QAAQ,WAAM,UAAU,CAAC,CAAA;AAGrC;;;;;;;;;;;;;GAaG;AACH;IACI;;;;;;;OAOG;IACH,YAAY,KAAkC,EAAE,QAAmB,EAAE,KAAK,GAAY,IAAI,EAAE,SAAS,GAAY,KAAK;QAClH,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QAEpB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC;QACtB,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAEvD,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,MAAc;YACtC,EAAE,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC;gBAAC,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAC5D,CAAC,CAAC,CAAC;IACP,CAAC;IAQD;;OAEG;IACH,IAAI,QAAQ;QACR,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAuFD,IAAI,CAAC,GAAG,IAAW;QACf,IAAI,QAAQ,GAA0B,IAAI,CAAC;QAC3C,IAAI,OAAO,GAAQ,IAAI,CAAC;QACxB,IAAI,UAAU,GAAQ,EAAE,CAAC;QAEzB,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,IA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AAe,EAE/B,CAAC;AAOF;;GAEG;AACI,gBAAO,GAA+C,EAAE,CAAC;AAjGvD,gBAAQ,WAoWpB,CAAA"}
\ No newline at end of file
diff --git a/dist/lib/InstanceInterface.js b/dist/lib/InstanceInterface.js
deleted file mode 100644
index 4b6c0d7..0000000
--- a/dist/lib/InstanceInterface.js
+++ /dev/null
@@ -1,2 +0,0 @@
-"use strict";
-//# sourceMappingURL=InstanceInterface.js.map
\ No newline at end of file
diff --git a/dist/lib/InstanceInterface.js.map b/dist/lib/InstanceInterface.js.map
deleted file mode 100644
index eb36d1f..0000000
--- a/dist/lib/InstanceInterface.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"InstanceInterface.js","sourceRoot":"","sources":["../../lib/InstanceInterface.ts"],"names":[],"mappings":""}
\ No newline at end of file
diff --git a/dist/lib/Middleware.js b/dist/lib/Middleware.js
deleted file mode 100644
index b652e4e..0000000
--- a/dist/lib/Middleware.js
+++ /dev/null
@@ -1,2 +0,0 @@
-"use strict";
-//# sourceMappingURL=Middleware.js.map
\ No newline at end of file
diff --git a/dist/lib/Middleware.js.map b/dist/lib/Middleware.js.map
deleted file mode 100644
index 9030c34..0000000
--- a/dist/lib/Middleware.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"Middleware.js","sourceRoot":"","sources":["../../lib/Middleware.ts"],"names":[],"mappings":""}
\ No newline at end of file
diff --git a/dist/lib/Model.js b/dist/lib/Model.js
deleted file mode 100644
index 6136dbe..0000000
--- a/dist/lib/Model.js
+++ /dev/null
@@ -1,469 +0,0 @@
-"use strict";
-const MongoDB = require("mongodb");
-const Bluebird = require("bluebird");
-const _ = require("lodash");
-const Core_1 = require("./Core");
-const Instance_1 = require("./Instance");
-const Cursor_1 = require("./Cursor");
-const ModelCache_1 = require("./ModelCache");
-const ModelHelpers_1 = require("./ModelHelpers");
-const ModelHandlers_1 = require("./ModelHandlers");
-const ModelSpecificInstance_1 = require("./ModelSpecificInstance");
-const Transforms_1 = require("./Transforms");
-/**
- * An Iridium Model which represents a structured MongoDB collection.
- * Models expose the methods you will generally use to query those collections, and ensure that
- * the results of those queries are returned as {TInstance} instances.
- *
- * @param TDocument The interface used to determine the schema of documents in the collection.
- * @param TInstance The interface or class used to represent collection documents in the JS world.
- *
- * @class
- */
-class Model {
- /**
- * Creates a new Iridium model representing a given ISchema and backed by a collection whose name is specified
- * @param core The Iridium core that this model should use for database access
- * @param instanceType The class which will be instantiated for each document retrieved from the database
- * @constructor
- */
- constructor(core, instanceType) {
- this._hooks = {};
- if (!(core instanceof Core_1.Core))
- throw new Error("You failed to provide a valid Iridium core for this model");
- if (typeof instanceType !== "function")
- throw new Error("You failed to provide a valid instance constructor for this model");
- if (typeof instanceType.collection !== "string" || !instanceType.collection)
- throw new Error("You failed to provide a valid collection name for this model");
- if (!_.isPlainObject(instanceType.schema) || instanceType.schema._id === undefined)
- throw new Error("You failed to provide a valid schema for this model");
- this._core = core;
- this.loadExternal(instanceType);
- this.onNewModel();
- this.loadInternal();
- }
- /**
- * Loads any externally available properties (generally accessed using public getters/setters).
- */
- loadExternal(instanceType) {
- this._collection = instanceType.collection;
- this._schema = instanceType.schema;
- this._hooks = instanceType;
- this._cacheDirector = instanceType.cache;
- this._transforms = instanceType.transforms || {};
- this._validators = instanceType.validators || [];
- this._indexes = instanceType.indexes || [];
- if (!this._schema._id)
- this._schema._id = MongoDB.ObjectID;
- if (this._schema._id === MongoDB.ObjectID && !this._transforms._id)
- this._transforms._id = Transforms_1.DefaultTransforms.ObjectID;
- if (instanceType.prototype instanceof Instance_1.Instance)
- this._Instance = ModelSpecificInstance_1.ModelSpecificInstance(this, instanceType);
- else
- this._Instance = instanceType.bind(undefined, this);
- }
- /**
- * Loads any internally (protected/private) properties and helpers only used within Iridium itself.
- */
- loadInternal() {
- this._cache = new ModelCache_1.ModelCache(this);
- this._helpers = new ModelHelpers_1.ModelHelpers(this);
- this._handlers = new ModelHandlers_1.ModelHandlers(this);
- }
- /**
- * Process any callbacks and plugin delegation for the creation of this model.
- * It will generally be called whenever a new Iridium Core is created, however is
- * more specifically tied to the lifespan of the models themselves.
- */
- onNewModel() {
- this._core.plugins.forEach(plugin => plugin.newModel && plugin.newModel(this));
- }
- /**
- * Provides helper methods used by Iridium for common tasks
- * @returns A set of helper methods which are used within Iridium for common tasks
- */
- get helpers() {
- return this._helpers;
- }
- /**
- * Provides helper methods used by Iridium for hook delegation and common processes
- * @returns A set of helper methods which perform common event and response handling tasks within Iridium.
- */
- get handlers() {
- return this._handlers;
- }
- /**
- * Gets the even hooks subscribed on this model for a number of different state changes.
- * These hooks are primarily intended to allow lifecycle manipulation logic to be added
- * in the user's model definition, allowing tasks such as the setting of default values
- * or automatic client-side joins to take place.
- */
- get hooks() {
- return this._hooks;
- }
- /**
- * Gets the schema dictating the data structure represented by this model.
- * The schema is used by skmatc to validate documents before saving to the database, however
- * until MongoDB 3.1 becomes widely available (with server side validation support) we are
- * limited in our ability to validate certain types of updates. As such, these validations
- * act more as a data-integrity check than anything else, unless you purely make use of Omnom
- * updates within instances.
- * @public
- * @returns The defined validation schema for this model
- */
- get schema() {
- return this._schema;
- }
- /**
- * Gets the Iridium core that this model is associated with.
- * @public
- * @returns The Iridium core that this model is bound to
- */
- get core() {
- return this._core;
- }
- /**
- * Gets the underlying MongoDB collection from which this model's documents are retrieved.
- * You can make use of this object if you require any low level access to the MongoDB collection,
- * however we recommend you make use of the Iridium methods whereever possible, as we cannot
- * guarantee the accuracy of the type definitions for the underlying MongoDB driver.
- * @public
- * @returns {Collection}
- */
- get collection() {
- if (!this.core.connection)
- throw new Error("Iridium Core not connected to a database.");
- return this.core.connection.collection(this._collection);
- }
- /**
- * Gets the name of the underlying MongoDB collection from which this model's documents are retrieved
- * @public
- */
- get collectionName() {
- return this._collection;
- }
- /**
- * Sets the name of the underlying MongoDB collection from which this model's documents are retrieved
- * @public
- */
- set collectionName(value) {
- this._collection = value;
- }
- /**
- * Gets the cache controller which dictates which queries will be cached, and under which key
- * @public
- * @returns {CacheDirector}
- */
- get cacheDirector() {
- return this._cacheDirector;
- }
- /**
- * Gets the cache responsible for storing objects for quick retrieval under certain conditions
- * @public
- * @returns {ModelCache}
- */
- get cache() {
- return this._cache;
- }
- /**
- * Gets the constructor responsible for creating instances for this model
- */
- get Instance() {
- return this._Instance;
- }
- /**
- * Gets the transforms which are applied whenever a document is received from the database, or
- * prior to storing a document in the database. Tasks such as converting an ObjectID to a string
- * and vice versa are all listed in this object.
- */
- get transforms() {
- return this._transforms;
- }
- /**
- * Gets the custom validation types available for this model. These validators are added to the
- * default skmatc validators, as well as those available through plugins, for use when checking
- * your instances.
- */
- get validators() {
- return this._validators;
- }
- /**
- * Gets the indexes which Iridium will manage on this model's database collection.
- */
- get indexes() {
- return this._indexes;
- }
- find(conditions, fields) {
- conditions = conditions || {};
- if (!_.isPlainObject(conditions))
- conditions = { _id: conditions };
- conditions = this._helpers.convertToDB(conditions);
- let cursor = this.collection.find(conditions);
- if (fields)
- cursor = cursor.project(fields);
- return new Cursor_1.Cursor(this, conditions, cursor);
- }
- get(...args) {
- return this.findOne.apply(this, args);
- }
- findOne(...args) {
- let conditions = null;
- let options = null;
- let callback = null;
- for (let argI = 0; argI < args.length; argI++) {
- if (typeof args[argI] === "function")
- callback = callback || args[argI];
- else if (_.isPlainObject(args[argI])) {
- if (conditions)
- options = args[argI];
- else
- conditions = args[argI];
- }
- else
- conditions = { _id: args[argI] };
- }
- conditions = conditions || {};
- options = options || {};
- _.defaults(options, {
- cache: true
- });
- return Bluebird.resolve().bind(this).then(() => {
- conditions = this._helpers.convertToDB(conditions);
- return this._cache.get(conditions);
- }).then((cachedDocument) => {
- if (cachedDocument)
- return cachedDocument;
- return new Bluebird((resolve, reject) => {
- let cursor = this.collection.find(conditions);
- if (options.sort)
- cursor = cursor.sort(options.sort);
- if (typeof options.skip === "number")
- cursor = cursor.skip(options.skip);
- cursor = cursor.limit(1);
- if (options.fields)
- cursor = cursor.project(options.fields);
- return cursor.next((err, result) => {
- if (err)
- return reject(err);
- return resolve(result);
- });
- });
- }).then((document) => {
- if (!document)
- return null;
- return this._handlers.documentReceived(conditions, document, (document, isNew, isPartial) => this._helpers.wrapDocument(document, isNew, isPartial), options);
- }).nodeify(callback);
- }
- create(...args) {
- return this.insert.apply(this, args);
- }
- insert(objs, ...args) {
- let objects;
- let options = {};
- let callback = null;
- if (typeof args[0] === "function")
- callback = args[0];
- else {
- options = args[0];
- callback = args[1];
- }
- if (Array.isArray(objs))
- objects = objs;
- else
- objects = [objs];
- options = options || {};
- _.defaults(options, {
- w: "majority",
- forceServerObjectId: true
- });
- return Bluebird.resolve().then(() => {
- let queryOptions = { w: options.w, upsert: options.upsert, new: true };
- if (options.upsert) {
- let docs = this._handlers.creatingDocuments(objects);
- return docs.map((object) => {
- return new Bluebird((resolve, reject) => {
- this.collection.findOneAndUpdate({ _id: object._id }, object, {
- upsert: options.upsert,
- returnOriginal: false
- }, (err, result) => {
- if (err)
- return reject(err);
- return resolve(result.value);
- });
- });
- });
- }
- else
- return this._handlers.creatingDocuments(objects).then(objects => _.chunk(objects, 1000)).map((objects) => {
- return new Bluebird((resolve, reject) => {
- this.collection.insertMany(objects, queryOptions, (err, result) => {
- if (err)
- return reject(err);
- return resolve(result.ops);
- });
- });
- }).then(results => _.flatten(results));
- }).map((inserted) => {
- return this._handlers.documentReceived(null, inserted, (document, isNew, isPartial) => this._helpers.wrapDocument(document, isNew, isPartial), { cache: options.cache });
- }).then((results) => {
- if (Array.isArray(objs))
- return results;
- return results[0];
- }).nodeify(callback);
- }
- update(conditions, changes, options, callback) {
- if (typeof options === "function") {
- callback = options;
- options = {};
- }
- options = options || {};
- if (!_.isPlainObject(conditions))
- conditions = {
- _id: conditions
- };
- _.defaults(options, {
- w: "majority",
- multi: true
- });
- return Bluebird.resolve().then(() => {
- conditions = this._helpers.convertToDB(conditions);
- return new Bluebird((resolve, reject) => {
- this.collection.updateMany(conditions, changes, options, (err, response) => {
- if (err)
- return reject(err);
- // New MongoDB 2.6+ response type
- if (response.result && response.result.nModified !== undefined)
- return resolve(response.result.nModified);
- // Legacy response type
- return resolve(response.result.n);
- });
- });
- }).nodeify(callback);
- }
- count(conds, callback) {
- let conditions = conds;
- if (typeof conds === "function") {
- callback = conds;
- conditions = {};
- }
- conditions = conditions || {};
- if (!_.isPlainObject(conditions))
- conditions = {
- _id: conditions
- };
- return Bluebird.resolve().then(() => {
- conditions = this._helpers.convertToDB(conditions);
- return new Bluebird((resolve, reject) => {
- this.collection.count(conditions, (err, results) => {
- if (err)
- return reject(err);
- return resolve(results);
- });
- });
- }).nodeify(callback);
- }
- remove(conds, options, callback) {
- let conditions = conds;
- if (typeof options === "function") {
- callback = options;
- options = {};
- }
- if (typeof conds === "function") {
- callback = conds;
- options = {};
- conditions = {};
- }
- conditions = conditions || {};
- options = options || {};
- _.defaults(options, {
- w: "majority"
- });
- if (!_.isPlainObject(conditions))
- conditions = {
- _id: conditions
- };
- return Bluebird.resolve().then(() => {
- conditions = this._helpers.convertToDB(conditions);
- return new Bluebird((resolve, reject) => {
- if (options.single)
- return this.collection.deleteOne(conditions, options, (err, response) => {
- if (err)
- return reject(err);
- return resolve(response.result.n);
- });
- this.collection.deleteMany(conditions, options, (err, response) => {
- if (err)
- return reject(err);
- return resolve(response.result.n);
- });
- });
- }).then((count) => {
- if (count === 1)
- this._cache.clear(conditions);
- return Bluebird.resolve(count);
- }).nodeify(callback);
- }
- aggregate(pipeline) {
- return new Bluebird((resolve, reject) => {
- this.collection.aggregate(pipeline, (err, results) => {
- if (err)
- return reject(err);
- return resolve(results);
- });
- });
- }
- ensureIndex(specification, options, callback) {
- if (typeof options === "function") {
- callback = options;
- options = {};
- }
- return new Bluebird((resolve, reject) => {
- this.collection.createIndex(specification, options, (err, name) => {
- if (err)
- return reject(err);
- return resolve(name);
- });
- }).nodeify(callback);
- }
- /**
- * Ensures that all indexes defined in the model's options are created
- * @param {function(Error, String[])} callback A callback which is triggered when the operation completes
- * @returns {Promise} The names of the indexes
- */
- ensureIndexes(callback) {
- return Bluebird.resolve(this._indexes).map((index) => {
- return this.ensureIndex(index.spec || index, index.options || {});
- }).nodeify(callback);
- }
- dropIndex(specification, callback) {
- let index;
- if (typeof (specification) === "string")
- index = specification;
- else {
- index = _(specification).map((direction, key) => `${key}_${direction}`).reduce((x, y) => `${x}_${y}`);
- }
- return new Bluebird((resolve, reject) => {
- this.collection.dropIndex(index, (err, result) => {
- if (err)
- return reject(err);
- return resolve(!!result.ok);
- });
- }).nodeify(callback);
- }
- /**
- * Removes all indexes (except for _id) from the collection
- * @param {function(Error, Boolean)} callback A callback which is triggered when the operation completes
- * @returns {Promise} Whether the indexes were dropped
- */
- dropIndexes(callback) {
- return new Bluebird((resolve, reject) => {
- this.collection.dropIndexes((err, count) => {
- if (err)
- return reject(err);
- return resolve(count);
- });
- }).nodeify(callback);
- }
-}
-exports.Model = Model;
-//# sourceMappingURL=Model.js.map
\ No newline at end of file
diff --git a/dist/lib/Model.js.map b/dist/lib/Model.js.map
deleted file mode 100644
index d39bdcd..0000000
--- a/dist/lib/Model.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"Model.js","sourceRoot":"","sources":["../../lib/Model.ts"],"names":[],"mappings":";AAAA,MAAa,OAAO,WAAM,SAAS,CAAC,CAAA;AACpC,MAAY,QAAQ,WAAM,UAAU,CAAC,CAAA;AAErC,MAAa,CAAC,WAAM,QAAQ,CAAC,CAAA;AAG7B,uBAAmB,QAAQ,CAAC,CAAA;AAC5B,2BAAuB,YAAY,CAAC,CAAA;AAOpC,yBAAqB,UAAU,CAAC,CAAA;AAKhC,6BAAyB,cAAc,CAAC,CAAA;AACxC,+BAA2B,gBAAgB,CAAC,CAAA;AAC5C,gCAA4B,iBAAiB,CAAC,CAAA;AAE9C,wCAAoC,yBAAyB,CAAC,CAAA;AAE9D,6BAA4C,cAAc,CAAC,CAAA;AAG3D;;;;;;;;;GASG;AACH;IACI;;;;;OAKG;IACH,YAAY,IAAU,EAAE,Y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AAC,WAAW,CAAC,CAAC,GAAG,EAAE,KAAK;gBACnC,EAAE,CAAC,CAAC,GAAG,CAAC;oBAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;gBAC5B,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YAC1B,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACzB,CAAC;AACL,CAAC;AA3tBY,aAAK,QA2tBjB,CAAA"}
\ No newline at end of file
diff --git a/dist/lib/ModelCache.js b/dist/lib/ModelCache.js
deleted file mode 100644
index d885208..0000000
--- a/dist/lib/ModelCache.js
+++ /dev/null
@@ -1,29 +0,0 @@
-"use strict";
-const Bluebird = require("bluebird");
-/**
- * A centralized class which ties the cache and cache directors together in a cohesive way
- * for use by Iridium.
- * @internal
- */
-class ModelCache {
- constructor(model) {
- this.model = model;
- }
- set(value) {
- if (!this.model.cacheDirector || !this.model.cacheDirector.valid(value))
- return;
- this.model.core.cache.set(this.model.cacheDirector.buildKey(value), value);
- }
- get(conditions) {
- if (!this.model.cacheDirector || !this.model.cacheDirector.validQuery(conditions))
- return Bluebird.resolve(null);
- return Bluebird.resolve(this.model.core.cache.get(this.model.cacheDirector.buildQueryKey(conditions)));
- }
- clear(conditions) {
- if (!this.model.cacheDirector || !this.model.cacheDirector.validQuery(conditions))
- return;
- this.model.core.cache.clear(this.model.cacheDirector.buildQueryKey(conditions));
- }
-}
-exports.ModelCache = ModelCache;
-//# sourceMappingURL=ModelCache.js.map
\ No newline at end of file
diff --git a/dist/lib/ModelCache.js.map b/dist/lib/ModelCache.js.map
deleted file mode 100644
index d35e475..0000000
--- a/dist/lib/ModelCache.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"ModelCache.js","sourceRoot":"","sources":["../../lib/ModelCache.ts"],"names":[],"mappings":";AACA,MAAY,QAAQ,WAAM,UAAU,CAAC,CAAA;AAErC;;;;GAIG;AACH;IACI,YAA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lib/ModelHandlers.js
deleted file mode 100644
index f2691b3..0000000
--- a/dist/lib/ModelHandlers.js
+++ /dev/null
@@ -1,63 +0,0 @@
-"use strict";
-const _ = require("lodash");
-const Bluebird = require("bluebird");
-/**
- * Provides a number of methods which are used to handle events that occur within
- * the Iridium workflow - such as what happens when a document is received from
- * the database, or how to handle the creation of new documents and saving of instances.
- *
- * Mostly this is for cache support, wrapping and hook triggering.
- * @internal
- */
-class ModelHandlers {
- constructor(model) {
- this.model = model;
- }
- documentReceived(conditions, result, wrapper, options = {}) {
- _.defaults(options, {
- cache: true,
- partial: false
- });
- let wrapped;
- return Bluebird.resolve(this.model.helpers.transformFromDB(result, { document: true })).then((target) => {
- return Bluebird
- .resolve(this.model.hooks.onRetrieved && this.model.hooks.onRetrieved(target))
- .then(() => {
- // Cache the document if caching is enabled
- if (this.model.core.cache && options.cache && !options.fields) {
- this.model.cache.set(target); // Does not block execution pipeline - fire and forget
- }
- // Wrap the document and trigger the ready hook
- let wrapped = wrapper(target, false, !!options.fields);
- // Only incur the additional promise's performance penalty if this hook is being used
- if (this.model.hooks.onReady)
- return Bluebird
- .resolve(this.model.hooks.onReady(wrapped))
- .then(() => wrapped);
- return wrapped;
- });
- });
- }
- creatingDocuments(documents) {
- return Bluebird.all(documents.map((document) => {
- return Bluebird
- .resolve(this.model.hooks.onCreating && this.model.hooks.onCreating(document))
- .then(() => {
- document = this.model.helpers.convertToDB(document, { document: true, properties: true });
- let validation = this.model.helpers.validate(document);
- if (validation.failed)
- return Bluebird.reject(validation.error);
- return document;
- });
- }));
- }
- savingDocument(instance, changes) {
- return Bluebird
- .resolve(this.model.hooks.onSaving && this.model.hooks.onSaving(instance, changes))
- .then(() => {
- return instance;
- });
- }
-}
-exports.ModelHandlers = ModelHandlers;
-//# sourceMappingURL=ModelHandlers.js.map
\ No newline at end of file
diff --git a/dist/lib/ModelHandlers.js.map b/dist/lib/ModelHandlers.js.map
deleted file mode 100644
index 14dbd8f..0000000
--- a/dist/lib/Mod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AAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;aAClF,IAAI,CAAC;YACF,MAAM,CAAC,QAAQ,CAAC;QACpB,CAAC,CAAC,CAAC;IACX,CAAC;AACL,CAAC;AA7DY,qBAAa,gBA6DzB,CAAA"}
\ No newline at end of file
diff --git a/dist/lib/ModelHelpers.js b/dist/lib/ModelHelpers.js
deleted file mode 100644
index 1cd11d5..0000000
--- a/dist/lib/ModelHelpers.js
+++ /dev/null
@@ -1,131 +0,0 @@
-"use strict";
-const MongoDB = require("mongodb");
-const Skmatc = require("skmatc");
-const Omnom_1 = require("./utils/Omnom");
-const _ = require("lodash");
-/**
- * A number of helper methods used commonly within Iridium, they provide a means to transform,
- * validate, wrap and diff instances and documents. By keeping these methods in one place we
- * help to improve testability and reduce code duplication (mouse abuse) throughout the codebase.
- * @internal
- */
-class ModelHelpers {
- constructor(model) {
- this.model = model;
- this._validator = Skmatc.scope(model.schema);
- model.validators.forEach(validator => this._validator.register(validator));
- }
- /**
- * Validates a document to ensure that it matches the model's ISchema requirements
- * @param {any} document The document to validate against the ISchema
- * @returns {SkmatcCore.IResult} The result of the validation
- */
- validate(document) {
- return this._validator.validate(document);
- }
- /**
- * Wraps the given document in an instance wrapper for use throughout the application
- * @param {any} document The document to be wrapped as an instance
- * @param {Boolean} isNew Whether the instance originated from the database or was created by the application
- * @param {Boolean} isPartial Whether the document supplied contains all information present in the database
- * @returns {any} An instance which wraps this document
- */
- wrapDocument(document, isNew, isPartial) {
- return new this.model.Instance(document, isNew, isPartial);
- }
- /**
- * Converts the given document to its database form into a form
- * using the transforms defined on the model.
- * @param {any} document The document to be converted
- * @returns {any} The result of having transformed the document.
- * @remarks This is only really called from insert/create - as
- */
- transformToDB(document, options = { properties: true }) {
- if (options.document && this.model.transforms.$document)
- document = this.model.transforms.$document.toDB(document, "$document", this.model);
- if (!options.properties)
- return document;
- for (let property in this.model.transforms)
- if (property === "$document")
- continue;
- else if (document.hasOwnProperty(property)) {
- document[property] = this.model.transforms[property].toDB(document[property], property, this.model);
- }
- return document;
- }
- /**
- * Converts the given document from its database form using the
- * transforms defined on the model.
- * @param document The document to be converted.
- * @returns The result of having transformed the document.
- * @remarks Unlike the transformToDB function - this method only applies
- * document level transforms, as property level transforms are applied in
- * their relevant instance setters.
- */
- transformFromDB(document, options = { properties: true }) {
- if (options.document && this.model.transforms.$document)
- document = this.model.transforms.$document.fromDB(document, "$document", this.model);
- if (!options.properties)
- return document;
- for (let property in this.model.transforms)
- if (property === "$document")
- continue;
- else if (document.hasOwnProperty(property)) {
- document[property] = this.model.transforms[property].fromDB(document[property], property, this.model);
- }
- return document;
- }
- /**
- * Converts the given document to its database form into a form
- * using the transforms defined on the model.
- * @param document The document to be converted
- * @param processProperties Whether or not to process properties in addition
- * document level transforms.
- * @returns {any} A new document cloned from the original and transformed
- */
- convertToDB(document, options = { properties: true }) {
- let doc = this.cloneDocument(document);
- return this.transformToDB(doc, options);
- }
- /**
- * Performs a diff operation between two documents and creates a MongoDB changes object to represent the differences
- * @param {any} original The original document prior to changes being made
- * @param {any} modified The document after changes were made
- */
- diff(original, modified) {
- let omnom = new Omnom_1.Omnom();
- omnom.diff(original, modified);
- return omnom.changes;
- }
- /**
- * Clones the given document recursively, taking into account complex types like
- * Buffers correctly.
- *
- * @param {any} The document you wish to clone deeply.
- */
- cloneDocument(original) {
- return _.cloneDeepWith(original, (value) => {
- if (Buffer.isBuffer(value)) {
- return value;
- }
- if (value instanceof MongoDB.Binary) {
- return value;
- }
- if (value instanceof MongoDB.ObjectID) {
- return value;
- }
- });
- }
- /**
- * Clones the given document recursively, taking into account complex types like
- * Buffers correctly. Optimized for working with query documents instead of true
- * documents.
- *
- * @param {any} The document you wish to clone deeply.
- */
- cloneConditions(original) {
- return this.cloneDocument(original);
- }
-}
-exports.ModelHelpers = ModelHelpers;
-//# sourceMappingURL=ModelHelpers.js.map
\ No newline at end of file
diff --git a/dist/lib/ModelHelpers.js.map b/dist/lib/ModelHelpers.js.map
deleted file mode 100644
index d676232..0000000
--- a/dist/lib/ModelHelpers.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"ModelHelpers.js","sourceRoot":"","sources":["../../lib/ModelHelpers.ts"],"names":[],"mappings":";AAAA,MAAY,OAAO,WAAM,SAAS,CAAC,CAAA;AAEnC,MAAY,MAAM,WAAM,QAAQ,CAAC,CAAA;AACjC,wBAAoB,eAAe,CAAC,CAAA;AACpC,MAAY,CAAC,WAAM,QAAQ,CAAC,CAAA;AAG5B;;;;;GAKG;AACH;IACI,YAAmB,KAAkC;QAAlC,UAAK,GAAL,KAAK,CAA6B;QACjD,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC7C,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;IAC/E,CAAC;IAID;;;;OAIG;IACH,QAAQ,CAAC,QAAmB;QACxB,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC9C,CAAC;IAED;;;;;;OAMG;IACH,YAAY,CAAC,QAAmB,EAAE,KAAe,EAAE,SAAmB;QAClE,MAAM,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;IAC/D,CAAC;IAED;;;;;;OAMG;IACH,aAAa,CAAI,QAAW,EAAE,OAAO,GAAqB,EAAE,UAAU,EAAE,IAAI,EAAE;QAC1E,EAAE,CAAA,CAAC,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC;YACnD,QAAQ,GAAQ,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,WAAW,EAAE,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H,eAAe,CAAI,QAAW;QAC1B,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IACxC,CAAC;AACL,CAAC;AAlIY,oBAAY,eAkIxB,CAAA"}
\ No newline at end of file
diff --git a/dist/lib/ModelInterfaces.js b/dist/lib/ModelInterfaces.js
deleted file mode 100644
index acd3648..0000000
--- a/dist/lib/ModelInterfaces.js
+++ /dev/null
@@ -1,2 +0,0 @@
-"use strict";
-//# sourceMappingURL=ModelInterfaces.js.map
\ No newline at end of file
diff --git a/dist/lib/ModelInterfaces.js.map b/dist/lib/ModelInterfaces.js.map
deleted file mode 100644
index a93281e..0000000
--- a/dist/lib/ModelInterfaces.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"ModelInterfaces.js","sourceRoot":"","sources":["../../lib/ModelInterfaces.ts"],"names":[],"mappings":""}
\ No newline at end of file
diff --git a/dist/lib/ModelOptions.js b/dist/lib/ModelOptions.js
deleted file mode 100644
index 35117a5..0000000
--- a/dist/lib/ModelOptions.js
+++ /dev/null
@@ -1,2 +0,0 @@
-"use strict";
-//# sourceMappingURL=ModelOptions.js.map
\ No newline at end of file
diff --git a/dist/lib/ModelOptions.js.map b/dist/lib/ModelOptions.js.map
deleted file mode 100644
index 09c7cce..0000000
--- a/dist/lib/ModelOptions.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"ModelOptions.js","sourceRoot":"","sources":["../../lib/ModelOptions.ts"],"names":[],"mappings":""}
\ No newline at end of file
diff --git a/dist/lib/ModelSpecificInstance.js b/dist/lib/ModelSpecificInstance.js
deleted file mode 100644
index c462a86..0000000
--- a/dist/lib/ModelSpecificInstance.js
+++ /dev/null
@@ -1,49 +0,0 @@
-"use strict";
-const _ = require("lodash");
-/**
- * Creates a new subclass of the given instanceType which correctly performs property transforms
- * and associates the instance with the correct model when instantiated.
- *
- * @param TDocument The interface representing the structure of the documents found in the database.
- * @param TInstance The interface or class representing the documents after they have been wrapped in an instance.
- *
- * @param model The model which instances should be associated with when the resulting constructor is used.
- * @param instanceType The constructor used to create new instances of type TInstance.
- *
- * @internal
- */
-function ModelSpecificInstance(model, instanceType) {
- const instanceTypeConstructor = instanceType;
- let virtualClass = class extends instanceTypeConstructor {
- constructor(...args) {
- super(model, ...args);
- }
- }
- ;
- _.each(Object.keys(model.schema), (property) => {
- if (model.transforms.hasOwnProperty(property)) {
- return Object.defineProperty(virtualClass.prototype, property, {
- get: function () {
- return model.transforms[property].fromDB(this._modified[property], property, model);
- },
- set: function (value) {
- this._modified[property] = model.transforms[property].toDB(value, property, model);
- },
- enumerable: true,
- configurable: true
- });
- }
- Object.defineProperty(virtualClass.prototype, property, {
- get: function () {
- return this._modified[property];
- },
- set: function (value) {
- this._modified[property] = value;
- },
- enumerable: true
- });
- });
- return virtualClass;
-}
-exports.ModelSpecificInstance = ModelSpecificInstance;
-//# sourceMappingURL=ModelSpecificInstance.js.map
\ No newline at end of file
diff --git a/dist/lib/ModelSpecificInstance.js.map b/dist/lib/ModelSpecificInstance.js.map
deleted file mode 100644
index 689a40b..0000000
--- a/dist/lib/ModelSpecificInstance.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"ModelSpecificInstance.js","sourceRoot":"","sources":["../../lib/ModelSpecificInstance.ts"],"names":[],"mappings":";AAIA,MAAY,CAAC,WAAM,QAAQ,CAAC,CAAA;AAE5B;;;;;;;;;;;GAWG;AACH,+BAAkF,KAAkC,EAAE,YAA0D;IAC5K,MAAM,uBAAuB,GAA6B,YAAY,CAAC;IAEvE,IAAI,YAAY,GAAG,cAAc,uBAAuB;QACpD,YAAY,GAAG,IAAI;YACf,MAAM,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC;QAC1B,CAAC;IACL,CAAC;IAAA,CAAA;IAED,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAC,CAAC,QAAQ;QACtC,EAAE,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YAC5C,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,YAAY,CAAC,SAAS,EAAE,QAAQ,EAAE;gBAC3D,GAAG,EAAE;oBACD,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;gBACxF,CAAC;gBACD,GAAG,EAAE,UAAU,KAAK;oBAChB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;gBACvF,CAAC;gBACD,UAAU,EAAE,IAAI;gBAChB,YAAY,EAAE,IAAI;aACrB,CAAC,CAAC;QACP,CAAC;QAED,MAAM,CAAC,cAAc,CAAC,YAAY,CAAC,SAAS,EAAE,QAAQ,EAAE;YACpD,GAAG,EAAE;gBACD,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;YACpC,CAAC;YACD,GAAG,EAAE,UAAU,KAAK;gBAChB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC;YACrC,CAAC;YACD,UAAU,EAAE,IAAI;SACnB,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,MAAM,CAAM,YAAY,CAAC;AAC7B,CAAC;AAnCe,6BAAqB,wBAmCpC,CAAA"}
\ No newline at end of file
diff --git a/dist/lib/Plugins.js b/dist/lib/Plugins.js
deleted file mode 100644
index 1090f76..0000000
--- a/dist/lib/Plugins.js
+++ /dev/null
@@ -1,2 +0,0 @@
-"use strict";
-//# sourceMappingURL=Plugins.js.map
\ No newline at end of file
diff --git a/dist/lib/Plugins.js.map b/dist/lib/Plugins.js.map
deleted file mode 100644
index d04299e..0000000
--- a/dist/lib/Plugins.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"Plugins.js","sourceRoot":"","sources":["../../lib/Plugins.ts"],"names":[],"mappings":""}
\ No newline at end of file
diff --git a/dist/lib/Schema.js b/dist/lib/Schema.js
deleted file mode 100644
index 46a2f69..0000000
--- a/dist/lib/Schema.js
+++ /dev/null
@@ -1,2 +0,0 @@
-"use strict";
-//# sourceMappingURL=Schema.js.map
\ No newline at end of file
diff --git a/dist/lib/Schema.js.map b/dist/lib/Schema.js.map
deleted file mode 100644
index a5367a0..0000000
--- a/dist/lib/Schema.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"Schema.js","sourceRoot":"","sources":["../../lib/Schema.ts"],"names":[],"mappings":""}
\ No newline at end of file
diff --git a/dist/lib/Transforms.js b/dist/lib/Transforms.js
deleted file mode 100644
index ffccfc7..0000000
--- a/dist/lib/Transforms.js
+++ /dev/null
@@ -1,25 +0,0 @@
-"use strict";
-const BSON_1 = require("./BSON");
-exports.DefaultTransforms = {
- ObjectID: {
- fromDB: value => value instanceof BSON_1.ObjectID ? value.toHexString() : value,
- toDB: value => typeof value === "string" ? new BSON_1.ObjectID(value) : value
- },
- Binary: {
- fromDB: value => {
- if (!value)
- return null;
- if (value instanceof BSON_1.Binary)
- return value.buffer;
- return value;
- },
- toDB: value => {
- if (Buffer.isBuffer(value))
- return new BSON_1.Binary(value);
- if (Array.isArray(value))
- return new BSON_1.Binary(new Buffer(value));
- return null;
- }
- }
-};
-//# sourceMappingURL=Transforms.js.map
\ No newline at end of file
diff --git a/dist/lib/Transforms.js.map b/dist/lib/Transforms.js.map
deleted file mode 100644
index 09402cc..0000000
--- a/dist/lib/Transforms.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"Transforms.js","sourceRoot":"","sources":["../../lib/Transforms.ts"],"names":[],"mappings":";AAAA,uBAA+B,QAAQ,CAAC,CAAA;AAqC3B,yBAAiB,GAAG;IAC/B,QAAQ,EAA+B;QACvC,MAAM,EAAE,KAAK,IAAI,KAAK,YAAY,eAAQ,GAAG,KAAK,CAAC,WAAW,EAAE,GAAG,KAAK;QACxE,IAAI,EAAE,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,GAAG,IAAI,eAAQ,CAAC,KAAK,CAAC,GAAG,KAAK;KACtE;IACD,MAAM,EAA6B;QAClC,MAAM,EAAE,KAAK;YACZ,EAAE,CAAA,CAAC,CAAC,KAAK,CAAC;gBAAC,MAAM,CAAC,IAAI,CAAC;YACvB,EAAE,CAAA,CAAC,KAAK,YAAY,aAAM,CAAC;gBAAC,MAAM,CAAO,KAAM,CAAC,MAAM,CAAC;YAEvD,MAAM,CAAC,KAAK,CAAC;QACd,CAAC;QACD,IAAI,EAAE,KAAK;YACV,EAAE,CAAA,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;gBAAC,MAAM,CAAC,IAAI,aAAM,CAAC,KAAK,CAAC,CAAC;YACpD,EAAE,CAAA,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;gBAAC,MAAM,CAAC,IAAI,aAAM,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YAC9D,MAAM,CAAC,IAAI,CAAC;QACb,CAAC;KACD;CACD,CAAA"}
\ No newline at end of file
diff --git a/dist/lib/Validators.js b/dist/lib/Validators.js
deleted file mode 100644
index 95ed205..0000000
--- a/dist/lib/Validators.js
+++ /dev/null
@@ -1,15 +0,0 @@
-"use strict";
-const MongoDB = require("mongodb");
-const Skmatc = require("skmatc");
-function DefaultValidators() {
- return [
- Skmatc.create(schema => schema === MongoDB.ObjectID, function (schema, data) {
- return this.assert(!data || data instanceof MongoDB.ObjectID || (data._bsontype === "ObjectID" && data.id), "Expected " + JSON.stringify(data) + " to be a valid MongoDB.ObjectID object");
- }, { name: "ObjectID validation" }),
- Skmatc.create(schema => schema === Buffer, function (schema, data) {
- return this.assert(data && (data instanceof MongoDB.Binary || (data._bsontype === "Binary" && data.buffer)), "Expected " + JSON.stringify(data) + " to be a valid MongoDB.Binary object");
- }, { name: "Buffer validation" })
- ];
-}
-exports.DefaultValidators = DefaultValidators;
-//# sourceMappingURL=Validators.js.map
\ No newline at end of file
diff --git a/dist/lib/Validators.js.map b/dist/lib/Validators.js.map
deleted file mode 100644
index 1c40740..0000000
--- a/dist/lib/Validators.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"Validators.js","sourceRoot":"","sources":["../../lib/Validators.ts"],"names":[],"mappings":";AAAA,MAAY,OAAO,WAAM,SAAS,CAAC,CAAA;AACnC,MAAY,MAAM,WAAM,QAAQ,CAAC,CAAA;AAEjC;IACC,MAAM,CAAC;QACN,MAAM,CAAC,MAAM,CAAC,MAAM,IAAI,MAAM,KAAK,OAAO,CAAC,QAAQ,EAAE,UAAS,MAAM,EAAE,IAAI;YACzE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,IAAI,IAAI,YAAY,OAAO,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,SAAS,KAAK,UAAU,IAAI,IAAI,CAAC,EAAE,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,wCAAwC,CAAC,CAAC;QAC5L,CAAC,EAAE,EAAE,IAAI,EAAE,qBAAqB,EAAE,CAAC;QACnC,MAAM,CAAC,MAAM,CAAC,MAAM,IAAI,MAAM,KAAK,MAAM,EAAE,UAAS,MAAM,EAAE,IAAI;YAC/D,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,IAAI,YAAY,OAAO,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,SAAS,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,sCAAsC,CAAC,CAAC;QAC3L,CAAC,EAAE,EAAE,IAAI,EAAE,mBAAmB,EAAE,CAAC;KACjC,CAAC;AACH,CAAC;AATe,yBAAiB,oBAShC,CAAA"}
\ No newline at end of file
diff --git a/dist/lib/cacheControllers/IDDirector.js b/dist/lib/cacheControllers/IDDirector.js
deleted file mode 100644
index 1bab615..0000000
--- a/dist/lib/cacheControllers/IDDirector.js
+++ /dev/null
@@ -1,28 +0,0 @@
-"use strict";
-const MongoDB = require("mongodb");
-/**
- * Caches documents using their _id field as the unique cache key. This
- * is useful if you primarily query your documents using their _id field,
- * however can be suboptimal (or even a complete waste) if you use different
- * types of queries.
- */
-class CacheOnID {
- valid(object) {
- return !!object._id;
- }
- buildKey(object) {
- if (object._id._bsontype === "ObjectID")
- return new MongoDB.ObjectID(object._id.id).toHexString();
- return object._id;
- }
- validQuery(conditions) {
- return !!conditions._id;
- }
- buildQueryKey(conditions) {
- if (conditions._id._bsontype === "ObjectID")
- return new MongoDB.ObjectID(conditions._id.id).toHexString();
- return conditions._id;
- }
-}
-exports.CacheOnID = CacheOnID;
-//# sourceMappingURL=IDDirector.js.map
\ No newline at end of file
diff --git a/dist/lib/cacheControllers/IDDirector.js.map b/dist/lib/cacheControllers/IDDirector.js.map
deleted file mode 100644
index f8fe442..0000000
--- a/dist/lib/cacheControllers/IDDirector.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"IDDirector.js","sourceRoot":"","sources":["../../../lib/cacheControllers/IDDirector.ts"],"names":[],"mappings":";AACA,MAAY,OAAO,WAAM,SAAS,CAAC,CAAA;AAEnC;;;;;GAKG;AACH;IACI,KAAK,CAAC,MAAoB;QACtB,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;IACxB,CAAC;IAED,QAAQ,CAAC,MAAoB;QACzB,EAAE,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,KAAK,UAAU,CAAC;YACpC,MAAM,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;QAC7D,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC;IACtB,CAAC;IAED,UAAU,CAAC,UAAU;QACjB,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC;IAC5B,CAAC;IAED,aAAa,CAAC,UAAU;QACpB,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,KAAK,UAAU,CAAC;YACxC,MAAM,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;QACjE,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC;IAC1B,CAAC;AACL,CAAC;AApBY,iBAAS,YAoBrB,CAAA"}
\ No newline at end of file
diff --git a/dist/lib/caches/MemoryCache.js b/dist/lib/caches/MemoryCache.js
deleted file mode 100644
index f8b388a..0000000
--- a/dist/lib/caches/MemoryCache.js
+++ /dev/null
@@ -1,28 +0,0 @@
-"use strict";
-const Bluebird = require("bluebird");
-/**
- * A cache implementation which stores documents in an in-memory cache.
- *
- * Be aware that this is an incredibly simplistic implementation which doesn't manage
- * memory usage at all and is very likely NOT suitable for production use.
- */
-class MemoryCache {
- constructor() {
- this.cache = {};
- }
- set(key, value) {
- this.cache[key] = value;
- return Bluebird.resolve(value);
- }
- get(key) {
- return Bluebird.resolve(this.cache[key]);
- }
- clear(key) {
- let has = this.cache.hasOwnProperty(key);
- if (has)
- delete this.cache[key];
- return Bluebird.resolve(has);
- }
-}
-exports.MemoryCache = MemoryCache;
-//# sourceMappingURL=MemoryCache.js.map
\ No newline at end of file
diff --git a/dist/lib/caches/MemoryCache.js.map b/dist/lib/caches/MemoryCache.js.map
deleted file mode 100644
index 882b4e6..0000000
--- a/dist/lib/caches/MemoryCache.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"MemoryCache.js","sourceRoot":"","sources":["../../../lib/caches/MemoryCache.ts"],"names":[],"mappings":";AAAA,MAAY,QAAQ,WAAM,UAAU,CAAC,CAAA;AAGrC;;;;;GAKG;AACH;IAAA;QACY,UAAK,GAAQ,EAAE,CAAC;IAgB5B,CAAC;IAdG,GAAG,CAAI,GAAW,EAAE,KAAQ;QACxB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACxB,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;IAED,GAAG,CAAI,GAAW;QACd,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7C,CAAC;IAED,KAAK,CAAC,GAAW;QACb,IAAI,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;QACzC,EAAE,CAAA,CAAC,GAAG,CAAC;YAAC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC/B,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACjC,CAAC;AACL,CAAC;AAjBY,mBAAW,cAiBvB,CAAA"}
\ No newline at end of file
diff --git a/dist/lib/caches/NoOpCache.js b/dist/lib/caches/NoOpCache.js
deleted file mode 100644
index ba59586..0000000
--- a/dist/lib/caches/NoOpCache.js
+++ /dev/null
@@ -1,22 +0,0 @@
-"use strict";
-const Bluebird = require("bluebird");
-/**
- * A cache implementation which does not cache any received documents
- * and returns nothing when requested - mimicking an empty cache.
- *
- * This is the default cache used if one is not supplied and should
- * not impose any significant performance overhead.
- */
-class NoOpCache {
- set(key, object) {
- return Bluebird.resolve(object);
- }
- get(key) {
- return Bluebird.resolve();
- }
- clear(key) {
- return Bluebird.resolve(false);
- }
-}
-exports.NoOpCache = NoOpCache;
-//# sourceMappingURL=NoOpCache.js.map
\ No newline at end of file
diff --git a/dist/lib/caches/NoOpCache.js.map b/dist/lib/caches/NoOpCache.js.map
deleted file mode 100644
index 0b4ea79..0000000
--- a/dist/lib/caches/NoOpCache.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"NoOpCache.js","sourceRoot":"","sources":["../../../lib/caches/NoOpCache.ts"],"names":[],"mappings":";AACA,MAAY,QAAQ,WAAM,UAAU,CAAC,CAAA;AAErC;;;;;;GAMG;AACH;IACI,GAAG,CAAI,GAAW,EAAE,MAAS;QACzB,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;IAED,GAAG,CAAI,GAAW;QACd,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,GAAW;QACb,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;AACL,CAAC;AAZY,iBAAS,YAYrB,CAAA"}
\ No newline at end of file
diff --git a/dist/lib/middleware/Express.js b/dist/lib/middleware/Express.js
deleted file mode 100644
index 1e3662f..0000000
--- a/dist/lib/middleware/Express.js
+++ /dev/null
@@ -1,20 +0,0 @@
-"use strict";
-/**
- * A factory method which creates Express/Connect compatible middleware functions to inject
- * a "db" field on your request objects as well as ensuring that the Iridium Core is connected
- * to a MongoDB database before handling any requests.
- *
- * @internal
- */
-function ExpressMiddlewareFactory(core) {
- return function (req, res, next) {
- core.connect().then(function () {
- Object.defineProperty(req, "db", {
- get: function () { return core; }
- });
- next();
- }).catch(next);
- };
-}
-exports.ExpressMiddlewareFactory = ExpressMiddlewareFactory;
-//# sourceMappingURL=Express.js.map
\ No newline at end of file
diff --git a/dist/lib/middleware/Express.js.map b/dist/lib/middleware/Express.js.map
deleted file mode 100644
index 1bdf548..0000000
--- a/dist/lib/middleware/Express.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"Express.js","sourceRoot":"","sources":["../../../lib/middleware/Express.ts"],"names":[],"mappings":";AAIA;;;;;;GAMG;AACH,kCAAyC,IAAU;IAC/C,MAAM,CAAC,UAAU,GAAuB,EAAE,GAAwB,EAAE,IAA0C;QAC1G,IAAI,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC;YAChB,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,IAAI,EAAE;gBAC7B,GAAG,EAAE,cAAa,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;aACnC,CAAC,CAAC;YACH,IAAI,EAAE,CAAC;QACX,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC,CAAC;AACN,CAAC;AATe,gCAAwB,2BASvC,CAAA"}
\ No newline at end of file
diff --git a/dist/lib/utils/ObjectID.js b/dist/lib/utils/ObjectID.js
deleted file mode 100644
index c5ae9f2..0000000
--- a/dist/lib/utils/ObjectID.js
+++ /dev/null
@@ -1,20 +0,0 @@
-"use strict";
-const MongoDB = require("mongodb");
-/**
- * Converts a string to an ObjectID instance - a shortcut for require("mongodb").ObjectID.createFromHexString
- *
- * @param value The string representation of the ObjectID you wish to create.
- * @returns A MongoDB ObjectID instance equivalent to the string you provided.
- *
- * You should be aware that this method performs no validation on the received string, MongoDB's ObjectID requires
- * that it either be a 12 byte UTF8 string, or a 24 byte hexadecimal string in order to be converted correctly.
- *
- * This method removes the need for your application to directly depend on MongoDB's Node.js client library,
- * which helps clean up your code a bit and reduces the headache of maintaining two different versions of the
- * library (since Iridium also has one).
- */
-function toObjectID(value) {
- return MongoDB.ObjectID.createFromHexString(value);
-}
-exports.toObjectID = toObjectID;
-//# sourceMappingURL=ObjectID.js.map
\ No newline at end of file
diff --git a/dist/lib/utils/ObjectID.js.map b/dist/lib/utils/ObjectID.js.map
deleted file mode 100644
index 13c08c0..0000000
--- a/dist/lib/utils/ObjectID.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"ObjectID.js","sourceRoot":"","sources":["../../../lib/utils/ObjectID.ts"],"names":[],"mappings":";AAAA,MAAY,OAAO,WAAM,SAAS,CAAC,CAAA;AAEnC;;;;;;;;;;;;GAYG;AACH,oBAA2B,KAAa;IACvC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;AACpD,CAAC;AAFe,kBAAU,aAEzB,CAAA"}
\ No newline at end of file
diff --git a/dist/lib/utils/Omnom.js b/dist/lib/utils/Omnom.js
deleted file mode 100644
index 825aa6a..0000000
--- a/dist/lib/utils/Omnom.js
+++ /dev/null
@@ -1,186 +0,0 @@
-"use strict";
-const _ = require("lodash");
-const MongoDB = require("mongodb");
-class Omnom {
- constructor(options = {}) {
- this.options = options;
- this._changes = {};
- }
- get changes() {
- return this._changes;
- }
- diff(original, modified) {
- this.onObject(original, modified);
- return this;
- }
- static diff(original, modified, options) {
- return new Omnom(options).diff(original, modified).changes;
- }
- onObject(original, modified, changePath) {
- if (original === undefined || original === null)
- return (original !== modified) && this.set(changePath, modified);
- if (typeof original === "number" && typeof modified === "number" && original !== modified) {
- if (this.options.atomicNumbers)
- return this.inc(changePath, modified - original);
- return this.set(changePath, modified);
- }
- if (Array.isArray(original) && Array.isArray(modified))
- return this.onArray(original, modified, changePath);
- if (original instanceof MongoDB.ObjectID && modified instanceof MongoDB.ObjectID)
- return !original.equals(modified) && this.set(changePath, modified);
- if (!_.isPlainObject(original) || !_.isPlainObject(modified))
- return !_.isEqual(original, modified) && this.set(changePath, modified);
- _.forOwn(modified, (value, key) => {
- // Handle array diffs in their own special way
- if (Array.isArray(value) && Array.isArray(original[key]))
- this.onArray(original[key], value, this.resolve(changePath, key));
- else
- this.onObject(original[key], value, this.resolve(changePath, key));
- }, this);
- // Unset removed properties
- _.forOwn(original, (value, key) => {
- if (modified[key] === undefined)
- return this.unset(this.resolve(changePath, key));
- }, this);
- }
- onArray(original, modified, changePath) {
- // Check if we can get from original => modified using just pulls
- if (original.length > modified.length) {
- return this.onSmallerArray(original, modified, changePath);
- }
- // Check if we can get from original => modified using just pushes
- if (original.length < modified.length) {
- return this.onLargerArray(original, modified, changePath);
- }
- // Otherwise, we need to use $set to generate the new array
- return this.onSimilarArray(original, modified, changePath);
- }
- onSmallerArray(original, modified, changePath) {
- let pulls = [];
- let i = 0;
- let j = 0;
- for (; i < original.length && j < modified.length; i++) {
- if (this.almostEqual(original[i], modified[j]))
- j++;
- else
- pulls.push(original[i]);
- }
- for (; i < original.length; i++)
- pulls.push(original[i]);
- if (j === modified.length) {
- if (pulls.length === 1)
- return this.pull(changePath, pulls[0]);
- // We can complete using just pulls
- return pulls.forEach((pull) => this.pull(changePath, pull));
- }
- else
- return this.set(changePath, modified);
- }
- onLargerArray(original, modified, changePath) {
- let canPush = true;
- for (let i = 0; i < original.length; i++)
- if (this.almostEqual(original[i], modified[i]) < 1) {
- canPush = false;
- break;
- }
- if (canPush) {
- for (let i = original.length; i < modified.length; i++)
- this.push(changePath, modified[i]);
- return;
- }
- return this.onSimilarArray(original, modified, changePath);
- }
- onSimilarArray(original, modified, changePath) {
- // Check how many manipulations would need to be performed, if it's more than half the array size
- // then rather re-create the array
- let sets = [];
- let partials = [];
- for (let i = 0; i < modified.length; i++) {
- let equality = this.almostEqual(original[i], modified[i]);
- if (equality === 0)
- sets.push(i);
- else if (equality < 1)
- partials.push(i);
- }
- if (sets.length > modified.length / 2)
- return this.set(changePath, modified);
- for (let i = 0; i < sets.length; i++)
- this.set(this.resolve(changePath, sets[i].toString()), modified[sets[i]]);
- for (let i = 0; i < partials.length; i++)
- this.onObject(original[partials[i]], modified[partials[i]], this.resolve(changePath, partials[i].toString()));
- }
- set(path, value) {
- if (!this.changes.$set)
- this.changes.$set = {};
- this.changes.$set[path] = value;
- }
- unset(path) {
- if (!this.changes.$unset)
- this.changes.$unset = {};
- this.changes.$unset[path] = 1;
- }
- inc(path, value) {
- if (!this.changes.$inc)
- this.changes.$inc = {};
- this.changes.$inc[path] = value;
- }
- push(path, value) {
- if (!this.changes.$push)
- this.changes.$push = {};
- if (this.changes.$push[path]) {
- if (this.changes.$push[path].$each)
- this.changes.$push[path].$each.push(value);
- else
- this.changes.$push[path] = { $each: [this.changes.$push[path], value] };
- }
- else
- this.changes.$push[path] = value;
- }
- pull(path, value) {
- if (!this.changes.$pull)
- this.changes.$pull = {};
- if (this.changes.$pullAll && this.changes.$pullAll[path]) {
- return this.changes.$pullAll[path].push(value);
- }
- if (this.changes.$pull[path]) {
- this.pullAll(path, [this.changes.$pull[path], value]);
- delete this.changes.$pull[path];
- if (_.keys(this.changes.$pull).length === 0)
- delete this.changes.$pull;
- return;
- }
- this.changes.$pull[path] = value;
- }
- pullAll(path, values) {
- if (!this.changes.$pullAll)
- this.changes.$pullAll = {};
- this.changes.$pullAll[path] = values;
- }
- resolve(...args) {
- let validArguments = [];
- args.forEach(function (arg) {
- if (arg)
- validArguments.push(arg);
- });
- return validArguments.join(".");
- }
- almostEqual(o1, o2) {
- if (!_.isPlainObject(o1) || !_.isPlainObject(o2))
- return o1 == o2 ? 1 : 0;
- let object1KeyIndex, object1Keys = Object.keys(o1);
- let object2Keys = Object.keys(o2);
- let commonKeys = [];
- for (object1KeyIndex = 0; object1KeyIndex < object1Keys.length; object1KeyIndex++)
- if (~object2Keys.indexOf(object1Keys[object1KeyIndex]))
- commonKeys.push(object1Keys[object1KeyIndex]);
- let totalKeys = object1Keys.length + object2Keys.length - commonKeys.length;
- let keysDifference = totalKeys - commonKeys.length;
- let requiredChanges = 0;
- for (let i = 0; i < commonKeys.length; i++)
- if (this.almostEqual(o1[commonKeys[i]], o2[commonKeys[i]]) < 1)
- requiredChanges++;
- return 1 - (keysDifference / totalKeys) - (requiredChanges / commonKeys.length);
- }
-}
-exports.Omnom = Omnom;
-//# sourceMappingURL=Omnom.js.map
\ No newline at end of file
diff --git a/dist/lib/utils/Omnom.js.map b/dist/lib/utils/Omnom.js.map
deleted file mode 100644
index eae7474..0000000
--- a/dist/lib/utils/Omnom.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"Omnom.js","sourceRoot":"","sources":["../../../lib/utils/Omnom.ts"],"names":[],"mappings":";AAAA,MAAY,C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,EAAE,CAAC,CAAC;QAElC,IAAI,UAAU,GAAG,EAAE,CAAC;QACpB,GAAG,CAAC,CAAC,eAAe,GAAG,CAAC,EAAE,eAAe,GAAG,WAAW,CAAC,MAAM,EAAE,eAAe,EAAE;YAC7E,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC,CAAC;gBAAC,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC,CAAC;QAE1G,IAAI,SAAS,GAAG,WAAW,CAAC,MAAM,GAAG,WAAW,CAAC,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;QAC5E,IAAI,cAAc,GAAG,SAAS,GAAG,UAAU,CAAC,MAAM,CAAC;QAEnD,IAAI,eAAe,GAAG,CAAC,CAAC;QACxB,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE;YACtC,EAAE,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;gBAAC,eAAe,EAAE,CAAC;QAEtF,MAAM,CAAC,CAAC,GAAG,CAAC,cAAc,GAAG,SAAS,CAAC,GAAG,CAAC,eAAe,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;IACpF,CAAC;AACL,CAAC;AA7PY,aAAK,QA6PjB,CAAA"}
\ No newline at end of file
diff --git a/dist/main.d.ts b/dist/main.d.ts
deleted file mode 100644
index c69133f..0000000
--- a/dist/main.d.ts
+++ /dev/null
@@ -1,4075 +0,0 @@
-// Generated by typings
-// Source: dist/lib/middleware/Express.d.ts
-declare module '~iridium/dist/lib/middleware/Express' {
-import * as http from 'http';
-import { Core } from '~iridium/dist/lib/Core';
-/**
- * A factory method which creates Express/Connect compatible middleware functions to inject
- * a "db" field on your request objects as well as ensuring that the Iridium Core is connected
- * to a MongoDB database before handling any requests.
- *
- * @internal
- */
-export function ExpressMiddlewareFactory(core: Core): ExpressMiddleware;
-/**
- * An Express/Connect compatible middleware function which injects req.db and ensures that the Iridium Core
- * has an active database connection before continuing the request handling process.
- */
-export interface ExpressMiddleware {
- (req: http.ServerRequest, res: http.ServerResponse, next: (err?: Error, route?: String) => void): any;
-}
-}
-declare module 'iridium/dist/lib/middleware/Express' {
-import alias = require('~iridium/dist/lib/middleware/Express');
-export = alias;
-}
-
-// Generated by typings
-// Source: dist/lib/Core.d.ts
-declare module '~iridium/dist/lib/Core' {
-import * as Bluebird from '~iridium~bluebird';
-import * as MongoDB from '~iridium~mongodb';
-import { Configuration } from '~iridium/dist/lib/Configuration';
-import { Plugin } from '~iridium/dist/lib/Plugins';
-import * as ExpressMiddleware from '~iridium/dist/lib/middleware/Express';
-import { Cache } from '~iridium/dist/lib/Cache';
-/**
- * The Iridium Core, responsible for managing the connection to the database as well
- * as any plugins you are making use of.
- *
- * Generally you will subclass this to provide your own custom core with the models you
- * make use of within your application.
- */
-export class Core {
- /**
- * Creates a new Iridium Core instance connected to the specified MongoDB instance
- * @param {Iridium.IridiumConfiguration} config The config object defining the database to connect to
- * @constructs Core
- */
- constructor(config: Configuration);
- /**
- * Creates a new Iridium Core instance connected to the specified MongoDB instance
- * @param {String} url The URL of the MongoDB instance to connect to
- * @param {Iridium.IridiumConfiguration} config The config object made available as settings
- * @constructs Core
- */
- constructor(uri: string, config?: Configuration);
- private mongoConnectAsyc;
- private _plugins;
- private _url;
- private _config;
- private _connection;
- private _cache;
- private _connectPromise;
- /**
- * Gets the plugins registered with this Iridium Core
- * @returns {[Iridium.Plugin]}
- */
- plugins: Plugin[];
- /**
- * Gets the configuration specified in the construction of this
- * Iridium Core.
- * @returns {Iridium.Configuration}
- */
- settings: Configuration;
- /**
- * Gets the currently active database connection for this Iridium
- * Core.
- * @returns {MongoDB.Db}
- */
- connection: MongoDB.Db;
- /**
- * Gets the URL used to connect to MongoDB
- * @returns {String}
- */
- url: string;
- /**
- * Gets the cache used to store objects retrieved from the database for performance reasons
- * @returns {cache}
- */
- cache: Cache;
- /**
- * Registers a new plugin with this Iridium Core
- * @param {Iridium.Plugin} plugin The plugin to register with this Iridium Core
- * @returns {Iridium.Core}
- */
- register(plugin: Plugin): Core;
- /**
- * Connects to the database server specified in the provided configuration
- * @param {function(Error, Iridium.Core)} [callback] A callback to be triggered once the connection is established.
- * @returns {Promise}
- */
- connect(callback?: (err: Error, core: Core) => any): Bluebird;
- /**
- * Closes the active database connection
- * @type {Promise}
- */
- close(): Bluebird;
- /**
- * Provides an express middleware which can be used to set the req.db property
- * to the current Iridium instance.
- * @returns {Iridium.ExpressMiddleware}
- */
- express(): ExpressMiddleware.ExpressMiddleware;
- /**
- * A method which is called whenever a new connection is made to the database.
- *
- * @param connection The underlying MongoDB connection which was created, you can modify or replace this if you wish.
- * @returns A promise for the connection, allowing you to perform any asynchronous initialization required by your application.
- *
- * In subclassed Iridium Cores this method can be overridden to manipulate the properties
- * of the underlying MongoDB connection object, such as authenticating. Until this method
- * resolves a connection object, Iridium will be unable to execute any queries. If you wish
- * to run Iridium queries then look at the onConnected method.
- */
- protected onConnecting(connection: MongoDB.Db): Bluebird;
- /**
- * A method which is called once a database connection has been established and accepted by Iridium
- *
- * In subclassed Iridium cores this method can be overridden to perform tasks whenever a
- * connection to the database has been established - such as setting up indexes for your
- * collections or seeding the database.
- */
- protected onConnected(): Bluebird;
-}
-}
-declare module 'iridium/dist/lib/Core' {
-import alias = require('~iridium/dist/lib/Core');
-export = alias;
-}
-
-// Generated by typings
-// Source: https://raw.githubusercontent.com/typed-typings/npm-es6-promise/fb04188767acfec1defd054fc8024fafa5cd4de7/dist/es6-promise.d.ts
-declare module '~iridium~mongodb~es6-promise/dist/es6-promise' {
-export interface Thenable {
- then (onFulfilled?: (value: R) => U | Thenable, onRejected?: (error: any) => U | Thenable): Thenable;
- then (onFulfilled?: (value: R) => U | Thenable, onRejected?: (error: any) => void): Thenable;
-}
-
-export class Promise implements Thenable {
- /**
- * If you call resolve in the body of the callback passed to the constructor,
- * your promise is fulfilled with result object passed to resolve.
- * If you call reject your promise is rejected with the object passed to resolve.
- * For consistency and debugging (eg stack traces), obj should be an instanceof Error.
- * Any errors thrown in the constructor callback will be implicitly passed to reject().
- */
- constructor (callback: (resolve : (value?: R | Thenable) => void, reject: (error?: any) => void) => void);
-
- /**
- * onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects.
- * Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called.
- * Both callbacks have a single parameter , the fulfillment value or rejection reason.
- * "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve.
- * If an error is thrown in the callback, the returned promise rejects with that error.
- *
- * @param onFulfilled called when/if "promise" resolves
- * @param onRejected called when/if "promise" rejects
- */
- then (onFulfilled?: (value: R) => U | Thenable, onRejected?: (error: any) => U | Thenable): Promise;
- then (onFulfilled?: (value: R) => U | Thenable, onRejected?: (error: any) => void): Promise;
-
- /**
- * Sugar for promise.then(undefined, onRejected)
- *
- * @param onRejected called when/if "promise" rejects
- */
- catch (onRejected?: (error: any) => U | Thenable): Promise;
-
- /**
- * Make a new promise from the thenable.
- * A thenable is promise-like in as far as it has a "then" method.
- */
- static resolve (): Promise;
- static resolve (value: R | Thenable): Promise;
-
- /**
- * Make a promise that rejects to obj. For consistency and debugging (eg stack traces), obj should be an instanceof Error
- */
- static reject (error: any): Promise;
-
- /**
- * Make a promise that fulfills when every item in the array fulfills, and rejects if (and when) any item rejects.
- * the array passed to all can be a mixture of promise-like objects and other objects.
- * The fulfillment value is an array (in order) of fulfillment values. The rejection value is the first rejection value.
- */
- static all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable , T5 | Thenable, T6 | Thenable, T7 | Thenable, T8 | Thenable, T9 | Thenable, T10 | Thenable]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>;
- static all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable , T5 | Thenable, T6 | Thenable, T7 | Thenable, T8 | Thenable, T9 | Thenable]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>;
- static all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable , T5 | Thenable, T6 | Thenable, T7 | Thenable, T8 | Thenable]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>;
- static all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable , T5 | Thenable, T6 | Thenable, T7 | Thenable]): Promise<[T1, T2, T3, T4, T5, T6, T7]>;
- static all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable , T5 | Thenable, T6 | Thenable]): Promise<[T1, T2, T3, T4, T5, T6]>;
- static all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable , T5 | Thenable]): Promise<[T1, T2, T3, T4, T5]>;
- static all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable ]): Promise<[T1, T2, T3, T4]>;
- static all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable]): Promise<[T1, T2, T3]>;
- static all(values: [T1 | Thenable, T2 | Thenable]): Promise<[T1, T2]>;
- static all(values: [T1 | Thenable]): Promise<[T1]>;
- static all(values: Array>): Promise;
-
- /**
- * Make a Promise that fulfills when any item fulfills, and rejects if any item rejects.
- */
- static race (promises: (R | Thenable)[]): Promise;
-}
-
-/**
- * The polyfill method will patch the global environment (in this case to the Promise name) when called.
- */
-export function polyfill (): void;
-}
-declare module '~iridium~mongodb~es6-promise' {
-import alias = require('~iridium~mongodb~es6-promise/dist/es6-promise');
-export = alias;
-}
-
-// Generated by typings
-// Source: https://raw.githubusercontent.com/Think7/typings-mongodb/d4269a9c672ab28a7865b38c8614673e8aecc8e5/mongodb.d.ts
-declare module '~iridium~mongodb/mongodb' {
-// Type definitions for MongoDB v2.1
-// Project: https://github.com/mongodb/node-mongodb-native/tree/2.1
-// Definitions by: Andrew
-// Federico Caselli
-// Definitions: https://github.com/Think7/typings-mongodb
-
-// Documentation : http://mongodb.github.io/node-mongodb-native/2.1/api/
-
-// Use typings to install this type definition https://github.com/typings/typings
-
-import {EventEmitter} from 'events';
-import {Promise} from '~iridium~mongodb~es6-promise';
-
-// Class documentation : http://mongodb.github.io/node-mongodb-native/2.1/api/MongoClient.html
-export class MongoClient {
- constructor();
-
- static connect(uri: string, callback: MongoCallback): void;
- static connect(uri: string, options?: MongoClientOptions): Promise;
- static connect(uri: string, options: MongoClientOptions, callback: MongoCallback): void;
-
- connect(uri: string, callback: MongoCallback): void;
- connect(uri: string, options?: MongoClientOptions): Promise;
- connect(uri: string, options: MongoClientOptions, callback: MongoCallback): void;
-}
-
-export interface MongoCallback {
- (error: MongoError, result: T): void;
-}
-
-// http://mongodb.github.io/node-mongodb-native/2.1/api/MongoError.html
-export class MongoError extends Error {
- constructor(message: string);
- static create(options: Object): MongoError;
-}
-
-//http://mongodb.github.io/node-mongodb-native/2.1/api/MongoClient.html#.connect
-export interface MongoClientOptions {
- uri_decode_auth?: boolean;
- db?: DbCreateOptions;
- server?: ServerOptions;
- replSet?: ReplSetOptions;
- mongos?: MongosOptions;
- promiseLibrary?: Object;
-}
-
-// See : http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html
-export interface DbCreateOptions {
- authSource?: string;
- // the write concern for the operation where < 1 is no acknowlegement of write and w >= 1, w = ‘majority’ or tag acknowledges the write.
- w?: number | string;
- // set the timeout for waiting for write concern to finish (combines with w option).
- wtimeout?: number;
- j?: boolean;
- // use c++ bson parser. default:false.
- native_parser?: boolean;
- // force server to create _id fields instead of client. default:false.
- forceServerObjectId?: boolean;
- serializeFunctions?: boolean;
- ignoreUndefined?: boolean;
- // peform operations using raw bson buffers. default:false.
- raw?: boolean;
- // when deserializing a Long will fit it into a Number if it’s smaller than 53 bits. default:true.
- promoteLongs?: boolean;
- bufferMaxEntries?: number;
- // the prefered read preference. use 'ReadPreference' class.
- readPreference?: ReadPreference | string;
- // custom primary key factory to generate _id values (see Custom primary keys).
- pkFactory?: Object;
- promiseLibrary?: Object;
- readConcern?: { level?: Object };
-}
-
-// See http://mongodb.github.io/node-mongodb-native/2.1/api/ReadPreference.html
-export class ReadPreference {
- constructor(mode: string, tags: Object);
- mode: string;
- tags: any;
- static PRIMARY: string;
- static PRIMARY_PREFERRED: string;
- static SECONDARY: string;
- static SECONDARY_PREFERRED: string;
- static NEAREST: string;
- isValid(mode: string): boolean;
- static isValid(mode: string): boolean;
-}
-
-//http://mongodb.github.io/node-mongodb-native/2.1/api/Server.html
-export interface SocketOptions {
- // Reconnect on error. default:false
- autoReconnect?: boolean;
- // TCP Socket NoDelay option. default:true
- noDelay?: boolean;
- // TCP KeepAlive on the socket with a X ms delay before start. default:0
- keepAlive?: number;
- // TCP Connection timeout setting. default 0
- connectTimeoutMS?: number;
- // TCP Socket timeout setting. default 0
- socketTimeoutMS?: number;
-}
-
-//http://mongodb.github.io/node-mongodb-native/2.1/api/Server.html
-export interface ServerOptions {
- // - specify the number of connections in the pool default:5
- poolSize?: number;
- ssl?: boolean;
- sslValidate?: Object;
- checkServerIdentity?: boolean | Function;
- sslCA?: Array;
- sslCert?: Buffer | string;
- sslKey?: Buffer | string;
- sslPass?: Buffer | string;
- socketOptions?: SocketOptions;
- reconnectTries?: number;
- reconnectInterval?: number;
-}
-
-//http://mongodb.github.io/node-mongodb-native/2.1/api/ReplSet.html
-export interface ReplSetOptions {
- ha?: boolean;
- haInterval?: number;
- replicaSet?: string;
- secondaryAcceptableLatencyMS?: number;
- connectWithNoPrimary?: boolean;
- // - specify the number of connections in the pool default:5
- poolSize?: number;
- ssl?: boolean;
- sslValidate?: Object;
- checkServerIdentity?: boolean | Function;
- sslCA?: Array;
- sslCert?: Buffer | string;
- sslKey?: Buffer | string;
- sslPass?: Buffer | string;
- socketOptions?: SocketOptions;
-}
-
-//http://mongodb.github.io/node-mongodb-native/2.1/api/Mongos.html
-export interface MongosOptions {
- ha?: boolean;
- haInterval?: number;
- // - specify the number of connections in the pool default:5
- poolSize?: number;
- ssl?: boolean;
- sslValidate?: Object;
- checkServerIdentity?: boolean | Function;
- sslCA?: Array;
- sslCert?: Buffer | string;
- sslKey?: Buffer | string;
- sslPass?: Buffer | string;
- socketOptions?: SocketOptions;
-}
-
-// Class documentation : http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html
-export class Db extends EventEmitter {
- constructor(databaseName: string, serverConfig: Server | ReplSet | Mongos, options?: DbCreateOptions);
-
- serverConfig: Server | ReplSet | Mongos;
- bufferMaxEntries: number;
- databaseName: string;
- options: any;
- native_parser: boolean;
- slaveOk: boolean;
- writeConcern: any;
-
- // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#addUser
- addUser(username: string, password: string, callback: MongoCallback): void;
- addUser(username: string, password: string, options?: DbAddUserOptions): Promise;
- addUser(username: string, password: string, options: DbAddUserOptions, callback: MongoCallback): void;
- //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#admin
- admin(): Admin;
- // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#authenticate
- authenticate(userName: string, password: string, callback: MongoCallback): void;
- authenticate(userName: string, password: string, options?: { authMechanism: string }): Promise;
- authenticate(userName: string, password: string, options: { authMechanism: string }, callback: MongoCallback): void;
- // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#close
- close(callback: MongoCallback): void;
- close(forceClose?: boolean): Promise;
- close(forceClose: boolean, callback: MongoCallback): void;
- // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#collection
- collection(name: string): Collection;
- collection(name: string, callback: MongoCallback): Collection;
- collection(name: string, options: DbCollectionOptions, callback: MongoCallback): Collection;
- //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#collections
- collections(): Promise;
- collections(callback: MongoCallback): void;
- //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#command
- command(command: Object, callback: MongoCallback): void;
- command(command: Object, options?: { readPreference: ReadPreference | string }): Promise;
- command(command: Object, options: { readPreference: ReadPreference | string }, callback: MongoCallback): void;
- //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#createCollection
- createCollection(name: string, callback: MongoCallback): void;
- createCollection(name: string, options?: CollectionCreateOptions): Promise;
- createCollection(name: string, options: CollectionCreateOptions, callback: MongoCallback): void;
- //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#createIndex
- createIndex(name: string, fieldOrSpec: string | Object, callback: MongoCallback): void;
- createIndex(name: string, fieldOrSpec: string | Object, options?: IndexOptions): Promise;
- createIndex(name: string, fieldOrSpec: string | Object, options: IndexOptions, callback: MongoCallback): void;
- //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#db
- db(dbName: string): Db;
- db(dbName: string, options: { noListener?: boolean, returnNonCachedInstance?: boolean }): Db;
- //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#dropCollection
- dropCollection(name: string): Promise;
- dropCollection(name: string, callback: MongoCallback): void;
- // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#dropDatabase
- dropDatabase(): Promise;
- dropDatabase(callback: MongoCallback): void;
-
- //deprecated http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#ensureIndex
- // ensureIndex(collectionName: any, fieldOrSpec: any, options: IndexOptions, callback: Function): void;
- //deprecated http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#eval
- // eval(code: any, parameters: any[], options?: any, callback?: MongoCallback): void;
-
- //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#executeDbAdminCommand
- executeDbAdminCommand(command: Object, callback: MongoCallback): void;
- executeDbAdminCommand(command: Object, options?: { readPreference?: ReadPreference | string, maxTimeMS?: number }): Promise;
- executeDbAdminCommand(command: Object, options: { readPreference?: ReadPreference | string, maxTimeMS?: number }, callback: MongoCallback): void;
- // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#indexInformation
- indexInformation(name: string, callback: MongoCallback): void;
- indexInformation(name: string, options?: { full?: boolean, readPreference?: ReadPreference | string }): Promise;
- indexInformation(name: string, options: { full?: boolean, readPreference?: ReadPreference | string }, callback: MongoCallback): void;
- //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#listCollections
- listCollections(filter: { name?: string }, options?: { batchSize?: number, readPreference?: ReadPreference | string }): CommandCursor;
- //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#logout
- logout(callback: MongoCallback): void;
- logout(options?: { dbName?: string }): Promise;
- logout(options: { dbName?: string }, callback: MongoCallback): void;
- //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#open
- open(): Promise;
- open(callback: MongoCallback): void;
- //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#removeUser
- removeUser(username: string, callback: MongoCallback): void;
- removeUser(username: string, options?: { w?: number | string, wtimeout?: number, j?: boolean }): Promise;
- removeUser(username: string, options: { w?: number | string, wtimeout?: number, j?: boolean }, callback: MongoCallback): void;
- // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#renameCollection
- renameCollection(fromCollection: string, toCollection: string, callback: MongoCallback): void;
- renameCollection(fromCollection: string, toCollection: string, options?: { dropTarget?: boolean }): Promise;
- renameCollection(fromCollection: string, toCollection: string, options: { dropTarget?: boolean }, callback: MongoCallback): void;
- // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#stats
- stats(callback: MongoCallback): void;
- stats(options?: { scale?: number }): Promise;
- stats(options: { scale?: number }, callback: MongoCallback): void;
-}
-
-
-
-// Deprecated http://mongodb.github.io/node-mongodb-native/2.1/api/Server.html
-export class Server extends EventEmitter {
- constructor(host: string, port: number, options?: ServerOptions);
-
- connections(): Array;
-}
-
-// Deprecated http://mongodb.github.io/node-mongodb-native/2.1/api/ReplSet.html
-export class ReplSet extends EventEmitter {
- constructor(servers: Array, options?: ReplSetOptions);
-
- connections(): Array;
-}
-
-// Deprecated http://mongodb.github.io/node-mongodb-native/2.1/api/ReplSet.html
-export class Mongos extends EventEmitter {
- constructor(servers: Array, options?: MongosOptions);
-
- connections(): Array;
-}
-// http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#addUser
-export interface DbAddUserOptions {
- w?: string | number;
- wtimeout?: number;
- j?: boolean;
- customData?: Object;
- roles?: Object[];
-}
-
-//http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#createCollection
-export interface CollectionCreateOptions {
- w?: number | string;
- wtimeout?: number;
- j?: boolean;
- raw?: boolean;
- pkFactory?: Object;
- readPreference?: ReadPreference | string;
- serializeFunctions?: boolean;
- strict?: boolean;
- capped?: boolean;
- size?: number;
- max?: number;
- autoIndexId?: boolean;
-}
-
-// http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#collection
-export interface DbCollectionOptions {
- w?: number | string;
- wtimeout?: number;
- j?: boolean;
- raw?: boolean;
- pkFactory?: Object;
- readPreference?: ReadPreference | string;
- serializeFunctions?: boolean;
- strict?: boolean;
- readConcern?: { level: Object };
-}
-
-//http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#createIndex
-export interface IndexOptions {
- // The write concern.
- w?: number | string;
- // The write concern timeout.
- wtimeout?: number;
- // Specify a journal write concern.
- j?: boolean;
- // Creates an unique index.
- unique?: boolean;
- // Creates a sparse index.
- sparse?: boolean;
- // Creates the index in the background, yielding whenever possible.
- background?: boolean;
- // A unique index cannot be created on a key that has pre-existing duplicate values.
- // If you would like to create the index anyway, keeping the first document the database indexes and
- // deleting all subsequent documents that have duplicate value
- dropDups?: boolean;
- // For geo spatial indexes set the lower bound for the co-ordinates.
- min?: number;
- // For geo spatial indexes set the high bound for the co-ordinates.
- max?: number;
- // Specify the format version of the indexes.
- v?: number;
- // Allows you to expire data on indexes applied to a data (MongoDB 2.2 or higher)
- expireAfterSeconds?: number;
- // Override the auto generated index name (useful if the resulting name is larger than 128 bytes)
- name?: string;
-}
-
-// http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html
-export interface Admin {
- // http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#addUser
- addUser(username: string, password: string, callback: MongoCallback): void;
- addUser(username: string, password: string, options?: AddUserOptions): Promise;
- addUser(username: string, password: string, options: AddUserOptions, callback: MongoCallback): void;
- //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#authenticate
- authenticate(username: string, callback: MongoCallback): void;
- authenticate(username: string, password?: string): Promise;
- authenticate(username: string, password: string, callback: MongoCallback): void;
- //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#buildInfo
- buildInfo(): Promise;
- buildInfo(callback: MongoCallback): void;
- //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#command
- command(command: Object, callback: MongoCallback): void;
- command(command: Object, options?: { readPreference?: ReadPreference | string, maxTimeMS?: number }): Promise;
- command(command: Object, options: { readPreference?: ReadPreference | string, maxTimeMS?: number }, callback: MongoCallback): void;
- //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#listDatabases
- listDatabases(): Promise;
- listDatabases(callback: MongoCallback): void;
- //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#logout
- logout(): Promise;
- logout(callback: MongoCallback): void;
- //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#ping
- ping(): Promise;
- ping(callback: MongoCallback): void;
- //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#profilingInfo
- profilingInfo(): Promise;
- profilingInfo(callback: MongoCallback): void;
- //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#profilingLevel
- profilingLevel(): Promise;
- profilingLevel(callback: MongoCallback): void;
- //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#removeUser
- removeUser(username: string, callback: MongoCallback): void;
- removeUser(username: string, options?: FSyncOptions): Promise;
- removeUser(username: string, options: FSyncOptions, callback: MongoCallback): void;
- //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#replSetGetStatus
- replSetGetStatus(): Promise;
- replSetGetStatus(callback: MongoCallback): void;
- //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#serverInfo
- serverInfo(): Promise;
- serverInfo(callback: MongoCallback): void;
- //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#serverStatus
- serverStatus(): Promise;
- serverStatus(callback: MongoCallback): void;
- //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#setProfilingLevel
- setProfilingLevel(level: string): Promise;
- setProfilingLevel(level: string, callback: MongoCallback): void;
- // http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#validateCollection
- validateCollection(collectionNme: string, callback: MongoCallback): void;
- validateCollection(collectionNme: string, options?: Object): Promise;
- validateCollection(collectionNme: string, options: Object, callback: MongoCallback): void;
-}
-
-//http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#addUser
-export interface AddUserOptions {
- w?: number | string;
- wtimeout?: number;
- j?: boolean;
- fsync: boolean;
- customData?: Object;
- roles?: Object[]
-}
-
-//http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#removeUser
-export interface FSyncOptions {
- w?: number | string;
- wtimeout?: number;
- j?: boolean;
- fsync?: boolean
-}
-
-// Class documentation : http://mongodb.github.io/node-mongodb-native/2.1/api/ObjectID.html
-export class ObjectID {
- constructor(s?: string | number);
-
- generationTime: number;
-
- // Creates an ObjectID from a hex string representation of an ObjectID.
- // hexString – create a ObjectID from a passed in 24 byte hexstring.
- static createFromHexString(hexString: string): ObjectID;
- // Creates an ObjectID from a second based number, with the rest of the ObjectID zeroed out. Used for comparisons or sorting the ObjectID.
- // time – an integer number representing a number of seconds.
- static createFromTime(time: number): ObjectID;
- // Checks if a value is a valid bson ObjectId
- // id - Value to be checked
- static isValid(id: string | number): boolean;
- //Compares the equality of this ObjectID with otherID.
- equals(otherID: ObjectID): boolean;
- // Generate a 12 byte id string used in ObjectID's
- // time - optional parameter allowing to pass in a second based timestamp
- generate(time?: number): string;
- // Returns the generation date (accurate up to the second) that this ID was generated.
- getTimestamp(): Date;
- // Returns the ObjectID id as a 24 byte hex string representation
- toHexString(): string;
-}
-
-// Class documentation : http://mongodb.github.io/node-mongodb-native/2.1/api/Binary.html
-export class Binary {
- constructor(buffer: Buffer, subType?: number);
-
- static SUBTYPE_BYTE_ARRAY: number;
- static SUBTYPE_DEFAULT: number;
- static SUBTYPE_FUNCTION: number;
- static SUBTYPE_MD5: number;
- static SUBTYPE_USER_DEFINED: number;
- static SUBTYPE_UUID: number;
- static SUBTYPE_UUID_OLD: number;
-
- // The length of the binary.
- length(): number;
- // Updates this binary with byte_value
- put(byte_value: number | string): void;
- // Reads length bytes starting at position.
- read(position: number, length: number): Buffer;
- // Returns the value of this binary as a string.
- value(): string;
- // Writes a buffer or string to the binary
- write(buffer: Buffer | string, offset: number): void;
-}
-//http://mongodb.github.io/node-mongodb-native/2.1/api/Double.html
-export class Double {
- constructor(value: number);
-
- valueOf(): number;
-}
-
-//http://mongodb.github.io/node-mongodb-native/2.1/api/Long.html
-export class Long {
- constructor(low: number, high: number);
-
- static MAX_VALUE: Long;
- static MIN_VALUE: Long;
- static NEG_ONE: Long;
- static ONE: Long;
- static ZERO: Long;
-
- static fromBits(lowBits: number, highBits: number): Long;
- static fromInt(value: number): Long;
- static fromNumber(value: number): Long;
- static fromString(str: string, radix?: number): Long;
-
- add(other: Long): Long;
- and(other: Long): Long;
- compare(other: Long): number;
- div(other: Long): Long;
- equals(other: Long): boolean;
- getHighBits(): number;
- getLowBits(): number;
- getLowBitsUnsigned(): number;
- getNumBitsAbs(): number;
- greaterThan(other: Long): number;
- greaterThanOrEqual(other: Long): number;
- isNegative(): boolean;
- isOdd(): boolean;
- isZero(): boolean;
- lessThan(other: Long): boolean;
- lessThanOrEqual(other: Long): boolean;
- modulo(other: Long): Long;
- multiply(other: Long): Long;
- negate(): Long;
- not(): Long;
- notEquals(other: Long): boolean;
- or(other: Long): Long;
- shiftLeft(other: number): Long;
- shiftRight(other: number): Long;
- shiftRightUnsigned(other: number): Long;
- subtract(other: Long): Long;
- toInt(): number;
- toJSON(): string;
- toNumber(): number;
- toString(radix?: number): string;
- xor(other: Long): Long;
-}
-
-//http://mongodb.github.io/node-mongodb-native/2.1/api/MaxKey.html
-export class MaxKey { }
-
-//http://mongodb.github.io/node-mongodb-native/2.1/api/MinKey.html
-export class MinKey { }
-
-//http://mongodb.github.io/node-mongodb-native/2.1/api/Timestamp.html
-export class Timestamp {
- constructor(low: number, high: number);
-
- static MAX_VALUE: Timestamp;
- static MIN_VALUE: Timestamp;
- static NEG_ONE: Timestamp;
- static ONE: Timestamp;
- static ZERO: Timestamp;
-
- static fromBits(lowBits: number, highBits: number): Timestamp;
- static fromInt(value: number): Timestamp;
- static fromNumber(value: number): Timestamp;
- static fromString(str: string, radix?: number): Timestamp;
-
- add(other: Timestamp): Timestamp;
- and(other: Timestamp): Timestamp;
- compare(other: Timestamp): number;
- div(other: Timestamp): Timestamp;
- equals(other: Timestamp): boolean;
- getHighBits(): number;
- getLowBits(): number;
- getLowBitsUnsigned(): number;
- getNumBitsAbs(): number;
- greaterThan(other: Timestamp): number;
- greaterThanOrEqual(other: Timestamp): number;
- isNegative(): boolean;
- isOdd(): boolean;
- isZero(): boolean;
- lessThan(other: Timestamp): boolean;
- lessThanOrEqual(other: Timestamp): boolean;
- modulo(other: Timestamp): Timestamp;
- multiply(other: Timestamp): Timestamp;
- negate(): Timestamp;
- not(): Timestamp;
- notEquals(other: Timestamp): boolean;
- or(other: Timestamp): Timestamp;
- shiftLeft(other: number): Timestamp;
- shiftRight(other: number): Timestamp;
- shiftRightUnsigned(other: number): Timestamp;
- subtract(other: Timestamp): Timestamp;
- toInt(): number;
- toJSON(): string;
- toNumber(): number;
- toString(radix?: number): string;
- xor(other: Timestamp): Timestamp;
-}
-
-// Documentation : http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html
-export interface Collection {
- // Get the collection name.
- collectionName: string;
- // Get the full collection namespace.
- namespace: string;
- // The current write concern values.
- writeConcern: any;
- // The current read concern values.
- readConcern: any;
- // Get current index hint for collection.
- hint: any;
- //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#aggregate
- aggregate(pipeline: Object[], callback: MongoCallback): AggregationCursor;
- aggregate(pipeline: Object[], options?: CollectionAggregationOptions, callback?: MongoCallback): AggregationCursor;
- //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#bulkWrite
- bulkWrite(operations: Object[], callback: MongoCallback): void;
- bulkWrite(operations: Object[], options?: CollectionBluckWriteOptions): Promise;
- bulkWrite(operations: Object[], options: CollectionBluckWriteOptions, callback: MongoCallback): void;
- //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#count
- count(query: Object, callback: MongoCallback): void;
- count(query: Object, options?: MongoCountPreferences): Promise;
- count(query: Object, options: MongoCountPreferences, callback: MongoCallback): void;
- //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#createIndex
- createIndex(fieldOrSpec: string | any, callback: MongoCallback): void;
- createIndex(fieldOrSpec: string | any, options?: IndexOptions): Promise;
- createIndex(fieldOrSpec: string | any, options: IndexOptions, callback: MongoCallback): void;
- //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#createIndexes and http://docs.mongodb.org/manual/reference/command/createIndexes/
- createIndexes(indexSpecs: Object[]): Promise;
- createIndexes(indexSpecs: Object[], callback: MongoCallback): void;
- //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#deleteMany
- deleteMany(filter: Object, callback: MongoCallback): void;
- deleteMany(filter: Object, options?: CollectionOptions): Promise;
- deleteMany(filter: Object, options: CollectionOptions, callback: MongoCallback): void;
- //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#deleteOne
- deleteOne(filter: Object, callback: MongoCallback): void;
- deleteOne(filter: Object, options?: { w?: number | string, wtimmeout?: number, j?: boolean, bypassDocumentValidation?: boolean }): Promise;
- deleteOne(filter: Object, options: { w?: number | string, wtimmeout?: number, j?: boolean, bypassDocumentValidation?: boolean }, callback: MongoCallback): void;
- //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#distinct
- distinct(key: string, query: Object, callback: MongoCallback): void;
- distinct(key: string, query: Object, options?: { readPreference?: ReadPreference | string }): Promise;
- distinct(key: string, query: Object, options: { readPreference?: ReadPreference | string }, callback: MongoCallback): void;
- //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#drop
- drop(): Promise;
- drop(callback: MongoCallback): void;
- //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#dropIndex
- dropIndex(indexName: string, callback: MongoCallback): void;
- dropIndex(indexName: string, options?: CollectionOptions): Promise;
- dropIndex(indexName: string, options: CollectionOptions, callback: MongoCallback): void;
- // http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#dropIndexes
- dropIndexes(): Promise;
- dropIndexes(callback?: MongoCallback): void;
- //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#find
- find(query?: Object): Cursor;
- /** @deprecated */
- find(query: Object, fields?: Object, skip?: number, limit?: number, timeout?: number): Cursor;
- //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOne
- /** @deprecated use find().limit(1).next(function(err, doc){}) */
- findOne(filter: Object, callback: MongoCallback): void;
- /** @deprecated use find().limit(1).next(function(err, doc){}) */
- findOne(filter: Object, options?: FindOneOptions): Promise;
- /** @deprecated use find().limit(1).next(function(err, doc){}) */
- findOne(filter: Object, options: FindOneOptions, callback: MongoCallback): void;
- //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOneAndDelete
- findOneAndDelete(filter: Object, callback: MongoCallback): void;
- findOneAndDelete(filter: Object, options?: { projection?: Object, sort?: Object, maxTimeMS?: number }): Promise;
- findOneAndDelete(filter: Object, options: { projection?: Object, sort?: Object, maxTimeMS?: number }, callback: MongoCallback): void;
- //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOneAndReplace
- findOneAndReplace(filter: Object, replacement: Object, callback: MongoCallback): void;
- findOneAndReplace(filter: Object, replacement: Object, options?: FindOneAndReplaceOption): Promise;
- findOneAndReplace(filter: Object, replacement: Object, options: FindOneAndReplaceOption, callback: MongoCallback): void;
- //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOneAndUpdate
- findOneAndUpdate(filter: Object, update: Object, callback: MongoCallback