【发布时间】:2020-09-07 07:47:28
【问题描述】:
我现在正试图将我的头脑围绕会话.. 目前,我有一个 express/NodeJS 应用程序,它使用查询参数来存储看起来像这样的脚本中的值
脚本 sn-p:
curl localhost:3000/register?name=bob\&width=13.970000\&time=0
curl localhost:3000/wheels?left=0.000000\&right=0.000000\&time=0 --cookie "USER=bob"
curl localhost:3000/echo?dist=9.220000\&time=10 --cookie "USER=bob"
curl localhost:3000/line?l1=1\&l2=1\&l3=1\&time=20 --cookie "USER=bob"
curl localhost:3000/other?ir=0\&time=30 --cookie "USER=bob"
curl localhost:3000/wheels?left=3.000000\&right=3.000000\&time=100 --cookie "USER=bob"
curl localhost:3000/echo?dist=9.220000\&time=110 --cookie "USER=bob"
curl localhost:3000/line?l1=1\&l2=1\&l3=1\&time=120 --cookie "USER=bob"
curl localhost:3000/other?ir=0\&time=130 --cookie "USER=bob"
curl localhost:3000/wheels?left=3.000000\&right=3.000000\&time=200 --cookie "USER=bob"
curl localhost:3000/echo?dist=9.220000\&time=210 --cookie "USER=bob"
curl localhost:3000/line?l1=1\&l2=1\&l3=1\&time=220 --cookie "USER=bob"
我已经能够将每条数据从名称、宽度、左、右、l1、l2 等存储到 MySQL 上的数据库中。我什至创建了一个不错的 UI 来浏览数据库并对其进行过滤。我项目的下一部分是现在创建一种浏览各种会话并查看它们是否处于活动状态的方法......但是,我在尝试这样做时遇到了问题。
首先,一些问题:
- 如何将这些会话存储到 mysql?
- 会话如何链接到用户存储在 数据库?例如,当我创建 UI 来浏览特定 会话,我希望能够单击会话,然后查看 他们存储的名称、宽度、左、右、l1、l2 等信息 当该用户登录时?
我已经阅读了 express-sessions 文档,但对于我正在寻找的数据库信息,它确实有点模糊。如果这没有意义,那么我很抱歉。我发现对我来说一半的战斗是将我的问题用语言表达出来,但我正在尽我最大的努力学习 express、node js 和 mysql。任何帮助将不胜感激!
【问题讨论】:
标签: mysql node.js express session