我对redis& amp;节点,此刻我正在尝试遍历我创建的一些测试哈希键并打印出来以筛选结果。以下是我期望看到的结果:
{ "aaData": [['Tim Osbourne'],['Joe Bloggs'],['John Doe'],['Perry Coke'],['Will Holmes'],['Steven Smith']}
但我得到了这个结果:
{ "aaData": [[],[],[],[],[],[],]}'Tim Osbourne','Joe Bloggs','John Doe','Perry Coke','Will Holmes','Steven Smith',
这是我的代码:
app = require('../app'); var redis = require("redis"), client = redis.createClient(); routes = require('./'); var key_types = ''; client.keys("*", function (err, all_keys) { key_types += '{ "aaData": ['; all_keys.forEach(function (key, pos) { // use second arg of forEach to get pos key_types += "["; client.hmget([key, 'Owner of space'], function(err, field_val){ key_types = key_types + "'" + field_val + "',"; }); key_types += "],"; }); key_types += "]}"; }); app.get('/table_data', function(req, res){ res.render('table_data', { keys: key_types}); });
答案 0 :(得分:0)
keys *
async
模块(async.map)。 [key, 'Owner of space']
的目标是什么,因为'Owner of space'
始终会产生相同的结果?