Skip to content

Commit

Permalink
Merged master into release
Browse files Browse the repository at this point in the history
  • Loading branch information
notheotherben committed Feb 8, 2017
2 parents 7ed07e4 + 9161b8a commit c8d63f0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/Model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ export class Model<TDocument extends { _id?: any }, TInstance> {
let docs = this._handlers.creatingDocuments(objects);
return docs.map((object: { _id: any; }) => {
return new Bluebird<any[]>((resolve, reject) => {
this.collection.findOneAndUpdate({ _id: object._id }, object, {
this.collection.findOneAndUpdate({ _id: object._id || { $exists: false }}, object, {
upsert: options.upsert,
returnOriginal: false
}, (err, result) => {
Expand Down
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iridium",
"version": "7.1.0",
"version": "7.1.2",
"author": "Benjamin Pannell <admin@sierrasoftworks.com>",
"description": "A custom lightweight ORM for MongoDB designed for power-users",
"license": "MIT",
Expand Down Expand Up @@ -50,25 +50,25 @@
"node": ">= 6.0"
},
"dependencies": {
"@types/bluebird": "^3.0.33",
"@types/lodash": "^4.14.36",
"@types/mongodb": "^2.1.33",
"@types/chai": "^3.4.33",
"@types/bluebird": "^3.0.37",
"@types/lodash": "^4.14.52",
"@types/mongodb": "^2.1.38",
"@types/chai": "^3.4.34",
"bluebird": "^3.4.6",
"lodash": "^4.16.2",
"mongodb": "^2.2.11",
"skmatc": "~1.2.2"
},
"peerDependencies": {
"@types/bluebird": "^3.0.33",
"@types/lodash": "^4.14.36",
"@types/mongodb": "^2.1.33",
"@types/chai": "^3.4.33"
"@types/bluebird": "^3.0.37",
"@types/lodash": "^4.14.52",
"@types/mongodb": "^2.1.38",
"@types/chai": "^3.4.34"
},
"devDependencies": {
"@types/chai": "^3.4.34",
"@types/chai-as-promised": "^0.0.29",
"@types/mocha": "^2.2.32",
"@types/mocha": "^2.2.39",
"@types/source-map-support": "^0.2.28",
"chai": "^3.5.0",
"chai-as-promised": "^5.3.0",
Expand Down
2 changes: 1 addition & 1 deletion test/Hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Test extends Iridium.Instance<TestDocument, Test> {
}
}

describe("Hooks", function (this: Mocha) {
describe("Hooks", function() {
this.timeout(500);

let core = new Iridium.Core({ database: "test" });
Expand Down
8 changes: 8 additions & 0 deletions test/Model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ describe("Model",() => {
return chai.expect(model.create({ answer: 14 }, { upsert: true })).to.eventually.exist;
});

it("should generate an _id for new, upserted, documents", () => {
return chai.expect(model.create({ answer: 12 }, { upsert: true })).to.eventually.exist.and.have.property("_id").and.exist;
})

it("should return an error if you don't meet the schema validation requirements",() => {
return chai.expect(model.create(<any>{ answer: "wrong" })).to.eventually.be.rejected;
});
Expand Down Expand Up @@ -265,6 +269,10 @@ describe("Model",() => {
return chai.expect(model.insert({ answer: 14 }, { upsert: true })).to.eventually.exist;
});

it("should generate an _id for new, upserted, documents", () => {
return chai.expect(model.insert({ answer: 12 }, { upsert: true })).to.eventually.exist.and.have.property("_id").and.exist;
})

it("should return an error if you don't meet the schema validation requirements",() => {
return chai.expect(model.insert(<any>{ answer: "wrong" })).to.eventually.be.rejected;
});
Expand Down

0 comments on commit c8d63f0

Please sign in to comment.