我一直在寻找信息知道如何将Redis连接到Sails.js抛出模型 - 控制器 - 视图,我想我已经得到了它.
我的问题是,我认为我不理解Redis的哲学,它的键等.
我猜我的Redis没有任何钥匙,我的意思是它不是"名字:Victor,姓:Garcia"而是"Victor:García",没有钥匙,所以我不知道如何在模型中设置属性Redis的.
所以我尝试了没有设置属性或只设置整个键的属性(例如"Victor:Garcia:33:塞维利亚:西班牙"),但没有结果.
我的模型看起来像这样:
module.exports = {
schema: false,
connection: 'redis',
autoPK: false,
autoCreatedAt: false,
autoUpdatedAt: false,
attributes: {
ta : 'string',
// Override toJSON instance method
toJSON: function() {
var obj = this.toObject();
return obj;
}
}
};
Run Code Online (Sandbox Code Playgroud)
我试过这个:
Redis.find()
.where({ ta: 'MB:400V:TRAF004:EP:MvMoment' })
.exec(function(err, users) {
// Do stuff here
console.log("User: " + users + " - " + err);
});
Run Code Online (Sandbox Code Playgroud)
事实上,没有结果,我进入控制台:
User: - null
Run Code Online (Sandbox Code Playgroud)
不管我在哪里.
我也试过做这样的事情:
模型
module.exports = {
schema: false, …Run Code Online (Sandbox Code Playgroud)