fh-wfm-mongoose-store
Advanced tools
Comparing version 0.4.5 to 1.0.0-pre.1
@@ -6,41 +6,2 @@ 'use strict'; | ||
/** | ||
* | ||
* Creating a new object to be saved as a mongoose document | ||
* | ||
* @param objectToCreate | ||
*/ | ||
function create(objectToCreate) { | ||
var self = this; | ||
// needs a custom function because the created id is different | ||
// than the one in the request() topic | ||
var uid = objectToCreate.id; | ||
self.create(objectToCreate).then(function(createdObject) { | ||
self.mediator.publish([self.topics.getTopic('create', 'done'), uid].join(':'), createdObject); | ||
}).catch(function(err) { | ||
self.mediator.publish([self.topics.getTopic('create', 'error'), uid].join(':'), err); | ||
}); | ||
} | ||
/** | ||
* | ||
* Updating an existing object saved as a mongoose document | ||
* | ||
* @param objectToUpdate | ||
*/ | ||
function update(objectToUpdate) { | ||
var self = this; | ||
//The object being updated may not have had an id parameter set yet | ||
//when syncing. So the localuid is used as a query instead | ||
var uid = objectToUpdate.id || objectToUpdate._localuid; | ||
self.update(objectToUpdate).then(function(updatedObject) { | ||
self.mediator.publish([self.topics.getTopic('update', 'done'), uid].join(':'), updatedObject); | ||
}).catch(function(err) { | ||
self.mediator.publish([self.topics.getTopic('update', 'error'), uid].join(':'), err); | ||
}); | ||
} | ||
module.exports = function decorate(Class) { | ||
@@ -74,6 +35,6 @@ | ||
read: self.read, | ||
update: update, | ||
update: self.update, | ||
remove: self.remove, | ||
list: self.list, | ||
create: create | ||
create: self.create | ||
}); | ||
@@ -92,3 +53,2 @@ | ||
this.topics = new Topics(mediator); | ||
this.mediator = mediator; | ||
this.topics | ||
@@ -103,16 +63,4 @@ .prefix('wfm' + topicPrefix) | ||
filter = filter || {}; | ||
var _self = this; | ||
//(Optional) Different filters may require topic UIDs. | ||
//This can avoid the scenario where list done topics are publised with the | ||
//wrong results | ||
var topicUid = filter.topicUid; | ||
filter = _.omit(filter, 'topicUid'); | ||
crudlFunctions.list(filter).then(function(filteredList) { | ||
_self.mediator.publish(self.topics.getTopic('list', 'done', topicUid), filteredList); | ||
}).catch(function(err) { | ||
_self.mediator.publish(self.topics.getTopic('list', 'error', topicUid), err); | ||
}); | ||
return crudlFunctions.list(filter); | ||
}); | ||
@@ -119,0 +67,0 @@ |
{ | ||
"name": "fh-wfm-mongoose-store", | ||
"version": "0.4.5", | ||
"version": "1.0.0-pre.1", | ||
"description": "Direct mongoose storage", | ||
@@ -32,3 +32,3 @@ "main": "./lib/index.js", | ||
"bluebird": "3.5.0", | ||
"fh-wfm-mediator": "0.3.3", | ||
"fh-wfm-mediator": "1.0.0-pre.1", | ||
"lodash": "4.17.4", | ||
@@ -35,0 +35,0 @@ "moment": "^2.18.1", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37246
921
+ Addedfh-wfm-mediator@1.0.0-pre.1(transitive)
- Removedfh-wfm-mediator@0.3.3(transitive)
- Removedmediator-js@0.9.9(transitive)
Updatedfh-wfm-mediator@1.0.0-pre.1