在rethindb中使用节点插入错误

我是rethinkdb的新手。 当我尝试在https://github.com/rethinkdb/rethinkdb-example-nodejs/tree/master/todo-angular-express中的示例代码

function create(req, res, next) { var todo = req.body; todo.createdAt = r.now(); // Set the field `createdAt` to the current time r.table('todos').insert(todo, {returnVals: true}).run(req._rdbConn, function(error, result) { if (error) { handleError(res, error) } else if (result.inserted !== 1) { handleError(res, new Error("Document was not inserted.")) } else { res.send(JSON.stringify(result.new_val)); } next(); }); 

}

我得到了以下错误:

500内部服务器错误

{“error”:“return_vals改名为return_changes:\ nr.table(\”todos \“)。insert({”\“abcde \”\“),completed:r.json \“false \”),createdAt:r.now()},{returnVals:true})\ n

然后我尝试了http://rethinkdb.com/docs/examples/node-todo/中的示例代码

 function create(req, res, next) { var todo = req.body; // req.body was created by `bodyParser` todo.createdAt = r.now(); // Set the field `createdAt` to the current time r.table('todos').insert(todo, {returnChanges: true}).run(req._rdbConn, function(error, result) { if (error) { handleError(res, error) } else if (result.inserted !== 1) { handleError(res, new Error("Document was not inserted.")) } else { res.send(JSON.stringify(result.changes[0].new_val)); } next(); }); 

}

我有以下错误:

500内部服务器错误{“error”:“无法识别的可选参数returnChanges :\ nr.table(\”todos \“)。insert({title:r.json(\”\“abcde \”\“) :r.json(\“false \”),createdAt:r.now()},{returnChanges:true})\ n“}

看来rethinkdb已经改变了returnValsreturn_changes / returnChanges ,以及insert()的参数。

当我使用return_changes时,我遇到了问题。

最新版本插入的正确方法是什么? rethinkdb总是改变它的语法吗?

这确实是示例代码中的一个错误。 我已经打开https://github.com/rethinkdb/rethinkdb-example-nodejs/issues/3,所以我们可以修复它。

returnChanges无法识别的第二个问题可能来自使用旧的RethinkDB节点驱动程序。 你有没有尝试更新驱动程序? http://rethinkdb.com/docs/install-drivers/javascript/