Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace returnVals by returnChanges #13

Merged
merged 2 commits into from
May 20, 2015
Merged

Replace returnVals by returnChanges #13

merged 2 commits into from
May 20, 2015

Conversation

danielmewes
Copy link
Member

This should fix #11 and #12 .

@deontologician could you review please?

@@ -84,7 +84,7 @@ function* update(next) {
throw new Error("The todo must have a field `id`.");
}

var result = yield r.table('todos').get(todo.id).update(todo, {returnVals: true}).run(this._rdbConn);
var result = yield r.table('todos').get(todo.id).update(todo, {returnChanges: true}).run(this._rdbConn);
this.body = JSON.stringify(result.new_val);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line needs updating I believe.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which part of it?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry. I believe it should be result.changes[0].new_val -- but i'm not sure of the impact of only looking at [0]

and sometimes, there is no new_val property if there was no change (ie: they made the call but it was with identical data as what already was in the db.

I also noticed I didn't need to JSON.stringify. I think koa will do that for us.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right! Didn't think about it enough. I opened #14 so we don't forget changing that.

deontologician added a commit that referenced this pull request May 20, 2015
Replace returnVals by returnChanges
@deontologician deontologician merged commit cbe726b into master May 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

result.new_val; is undefined
3 participants