英文:
db.sadd is not a function?
问题
I'm trying to run some Node.js examples from the Express GitHub repository at this link. For this specific example, I ran npm update
and made sure that Redis in the root package.json
is "redis": "^4.6.7"
. However, I'm encountering an error related to the sadd
function not being present. I searched the Redis GitHub repository for sadd
but couldn't find its function definition. Does anyone know what's happening or how to further debug this?
$ node index.js
/home/vboxuser/src/nr/express/examples/search/index.js:28
db.sadd('ferret', 'tobi');
^
TypeError: db.sadd is not a function
at Object.<anonymous> (/home/vboxuser/src/nr/express/examples/search/index.js:28:4)
at Module._compile (node:internal/modules/cjs/loader:1218:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1272:10)
at Module.load (node:internal/modules/cjs/loader:1081:32)
at Module._load (node:internal/modules/cjs/loader:922:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47
Node.js v18.13.0
英文:
I'm trying to run some Nodejs examples from the Express examples GitHub at this link.
For this linked example, I ran npm update
and ensured Redis is in the root package.json
is "redis": "^4.6.7"
, however am receiving the following error about sadd
function not present. I searched Redis GitHub for sadd
and did not see the function definition.
Does anyone know what is going on or how to debug this further?
$ node index.js
/home/vboxuser/src/nr/express/examples/search/index.js:28
db.sadd('ferret', 'tobi');
^
TypeError: db.sadd is not a function
at Object.<anonymous> (/home/vboxuser/src/nr/express/examples/search/index.js:28:4)
at Module._compile (node:internal/modules/cjs/loader:1218:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1272:10)
at Module.load (node:internal/modules/cjs/loader:1081:32)
at Module._load (node:internal/modules/cjs/loader:922:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47
Node.js v18.13.0
答案1
得分: 0
这个示例是不正确的。正确的函数名称是.sAdd
或.SADD
。我通常使用.sAdd
,因为在代码中全大写感觉奇怪。我强烈鼓励您向他们发送一个拉取请求。
如果您遇到其他类似的问题,您可以在Node Redis README中找到几乎所有内容。
英文:
This example is incorrect. The correct function name is .sAdd
or .SADD
. I usually go with .sAdd
as all caps feels weird in code. I would heartily encourage you to send them a PR.
If you run into other issues like this, you can find the pretty much everything in or off of the Node Redis README.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论