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

result.new_val; is undefined #11

Closed
ralyodio opened this issue May 18, 2015 · 2 comments · Fixed by #13
Closed

result.new_val; is undefined #11

ralyodio opened this issue May 18, 2015 · 2 comments · Fixed by #13

Comments

@ralyodio
Copy link

In your create example, the result.new_val is undefined. Looks like maybe this has changed?

// Create a new todo
function* create(next) {
    try{
        var todo = yield parse(this);
        todo.createdAt = r.now(); // Set the field `createdAt` to the current time
        var result = yield r.table('todos').insert(todo, {returnVals: true}).run(this._rdbConn);

        todo = result.new_val; // todo now contains the previous todo + a field `id` and `createdAt`
        this.body = JSON.stringify(todo);
    }
    catch(e) {
        this.status = 500;
        this.body = e.message || http.STATUS_CODES[this.status];
    }
    yield next;
}
@coffeemug
Copy link

Related to #12.

Looks like the API has changed (in particular, returnVals was renamed to returnChanges), but the example hasn't been updated. Thanks @chovy. Could someone do a pull request?

@danielmewes
Copy link
Member

Opened a pull request #13

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 a pull request may close this issue.

3 participants