Skip to content

Commit

Permalink
fix: query with stateValue
Browse files Browse the repository at this point in the history
  • Loading branch information
Chunpeng Wen committed Sep 6, 2016
1 parent 68a7709 commit f0b5be3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions index.js
Expand Up @@ -62,10 +62,11 @@ module.exports = function (schema, options) {

if(_.isString(transition.from)) {
if('*' !== transition.from) {
query.state = transition.from;
query.stateValue = states[transition.from].value;
}
} else if(_.isArray(transition.from)) {
query.state = { $in: transition.from };
var fromValues = _.map(transition.from, function(from) { return states[from].value; });
query.stateValue = { $in: fromValues };
}


Expand Down Expand Up @@ -95,7 +96,7 @@ module.exports = function (schema, options) {
from = item.state;
exit = states[from].exit;

query.state = from;
query.stateValue = states[from].value;
Model.update(query, update).exec(function(err, r) {
if (err) {
return reject(err);
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "another-mongoose-statemachine",
"version": "1.6.2",
"version": "1.6.3",
"description": "State machine plugin for Mongoose ODM",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit f0b5be3

Please sign in to comment.