Skip to content

Commit

Permalink
chore: Update to support latest TypeScript compiler and MongoDB type …
Browse files Browse the repository at this point in the history
…definitions
  • Loading branch information
notheotherben committed Jun 9, 2017
1 parent fdc71d1 commit 33d7019
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
9 changes: 6 additions & 3 deletions lib/Model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ export class Model<TDocument extends { _id?: any }, TInstance> {

return cursor.next((err, result) => {
if (err) return reject(err);
return resolve(result);
return resolve(<TDocument|null>result);
});
});
}).then((document) => {
Expand Down Expand Up @@ -799,15 +799,18 @@ export class Model<TDocument extends { _id?: any }, TInstance> {
*/
dropIndex(index: Index.IndexSpecification, callback?: General.Callback<boolean>): Bluebird<boolean>;
dropIndex(specification: string | Index.IndexSpecification, callback?: General.Callback<boolean>): Bluebird<boolean> {
let index: string;
let index: string|undefined;

if (typeof (specification) === "string") index = <string>specification;
else {
index = _(<Index.IndexSpecification>specification).map((direction: number, key: string) => `${key}_${direction}`).reduce<string>((x, y) => `${x}_${y}`);
}

if (!index)
return Bluebird.reject(new Error("Expected a valid index name to be provided"));

return new Bluebird<boolean>((resolve, reject) => {
this.collection.dropIndex(index, (err: Error, result: { ok: number }) => {
this.collection.dropIndex(index!, (err: Error, result: { ok: number }) => {
if (err) return reject(err);
return resolve(<any>!!result.ok);
});
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@
"dependencies": {
"@types/bluebird": "^3.5.4",
"@types/lodash": "^4.14.64",
"@types/mongodb": "^2.2.2",
"@types/mongodb": "^2.2.4",
"@types/chai": "^3.5.2",
"bluebird": "^3.5.0",
"lodash": "^4.17.4",
"mongodb": "^2.2.26",
"mongodb": "^2.2.28",
"skmatc": "~1.2.2"
},
"peerDependencies": {
Expand Down
12 changes: 2 additions & 10 deletions test/Core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,20 +150,12 @@ describe("Core",() => {
let core = new Iridium.Core({
database: "test",
options: {
server: {
socketOptions: {
connectTimeoutMS: 1000
}
}
connectTimeoutMS: 1000
}
});

chai.expect(core.settings!.options).to.eql({
server: {
socketOptions: {
connectTimeoutMS: 1000
}
}
connectTimeoutMS: 1000
});
});
});
Expand Down

0 comments on commit 33d7019

Please sign in to comment.