Skip to content

Commit

Permalink
Cleaning up some code in Model to meet coding standards
Browse files Browse the repository at this point in the history
  • Loading branch information
notheotherben committed Jun 11, 2015
1 parent 55b0179 commit 4507857
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lib/Model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export default class Model<TDocument extends { _id?: any }, TInstance> implement
if (!_.isPlainObject(conditions)) conditions = { _id: conditions };

if (conditions.hasOwnProperty('_id'))
conditions['_id'] = this.options.identifier.reverse(conditions['_id']);
conditions._id = this.options.identifier.reverse(conditions._id);

var cursor = this.collection.find(conditions, {
fields: fields
Expand Down Expand Up @@ -338,7 +338,7 @@ export default class Model<TDocument extends { _id?: any }, TInstance> implement

return Bluebird.resolve().bind(this).then(() => {
if (conditions.hasOwnProperty('_id'))
conditions['_id'] = this.options.identifier.reverse(conditions['_id']);
conditions._id = this.options.identifier.reverse(conditions._id);

return this._cache.get<TDocument>(conditions);
}).then((cachedDocument: TDocument) => {
Expand Down Expand Up @@ -434,7 +434,6 @@ export default class Model<TDocument extends { _id?: any }, TInstance> implement
callback = args[1];
}

var returnArray: boolean = false;
if (Array.isArray(objs))
objects = <TDocument[]>objs;
else
Expand Down Expand Up @@ -511,7 +510,7 @@ export default class Model<TDocument extends { _id?: any }, TInstance> implement

return Bluebird.resolve().then(() => {
if (conditions.hasOwnProperty('_id'))
conditions['_id'] = this.options.identifier.reverse(conditions['_id']);
conditions._id = this.options.identifier.reverse(conditions._id);

return new Bluebird<number>((resolve, reject) => {
this.collection.updateMany(conditions, changes, options,(err, response) => {
Expand Down Expand Up @@ -554,7 +553,7 @@ export default class Model<TDocument extends { _id?: any }, TInstance> implement

return Bluebird.resolve().then(() => {
if (conditions.hasOwnProperty('_id'))
conditions['_id'] = this.options.identifier.reverse(conditions['_id']);
conditions._id = this.options.identifier.reverse(conditions._id);

return new Bluebird<number>((resolve, reject) => {
this.collection.count(conditions,(err, results) => {
Expand Down Expand Up @@ -611,7 +610,7 @@ export default class Model<TDocument extends { _id?: any }, TInstance> implement

return Bluebird.resolve().then(() => {
if (conditions.hasOwnProperty('_id'))
conditions['_id'] = this.options.identifier.reverse(conditions['_id']);
conditions._id = this.options.identifier.reverse(conditions._id);

return new Bluebird<number>((resolve, reject) => {
this.collection.remove(conditions, options,(err, response) => {
Expand Down

0 comments on commit 4507857

Please sign in to comment.