rethinkdb / rethinkdb-example-nodejs

137 stars 98 forks source link

`result.new_val;` is undefined #11

Closed ralyodio closed 9 years ago

ralyodio commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

Opened a pull request https://github.com/rethinkdb/rethinkdb-example-nodejs/pull/13