3
我是新来的rethinkDB,我试图通过使用过滤器函数的用户名来查找数据。 但是,即使有数据存在,rethinkDB也会返回null。Rethinkdb查询总是返回null尽管数据存在吗?
//Define Your Api//Define Your Api
import express from 'express';
import r from 'rethinkdb';
const router = express.Router();
router.post('/users',(req,res)=>{
let username = req.body.data.username;
let password = req.body.data.password;
console.log(username,password);
r.connect({db:"image"}).then((conn) => {
r.table("users").filter({username:"arfo"}).run(conn,function (err, data) {
console.log(data) //null
})
})
});
export default router
更新
它返回我一堆这样的数据我一定要操作该数据
Cursor {
_type: 3,
_eachCb: [Function],
_conn:
TcpConnection {
host: 'localhost',
port: 28015,
db: 'image',
authKey: '',
timeout: 20,
ssl: false,
outstandingCallbacks: {},
nextToken: 2,
open: true,
closing: false,
buffer: <Buffer >,
_events: {},
_eventsCount: NaN,
_closePromise: null,
rawSocket:
Socket {
connecting: false,
_hadError: false,
_handle: [Object],
_parent: null,
_host: 'localhost',
_readableState: [Object],
readable: true,
domain: null,
_events: [Object],
_eventsCount: 7,
_maxListeners: undefined,
_writableState: [Object],
writable: true,
allowHalfOpen: false,
destroyed: false,
_bytesDispatched: 325,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: null,
_server: null,
user: 'admin',
password: '',
read: [Function],
_consuming: true } },
_token: 1,
_opts: {},
_root: { [Function] args: [ [Object], [Object] ], optargs: {} },
_responses: [ { t: 2, r: [Object], n: [] } ],
_responseIndex: 0,
_outstandingRequests: 0,
_iterations: 0,
_endFlag: true,
_contFlag: false,
_closeAsap: false,
_cont: null,
_cbQueue: [],
_closeCb: null,
_closeCbPromise: null,
next: [Function] }
看得出来更新它不工作 – Nane
rethinkDB有没有问题 – Nane
我已经更新了我的答案。我想你可能需要在游标上调用'toArray()'。查看故障诊断文档:https://www.rethinkdb.com/docs/troubleshooting/ – dan