0

我想在 Redis 数据库中以以下样式存储数据:

 { _id: 5b3a60cdccbdf81bcc5343e6,
    id: 5b3a60cdccbdf81bcc5343e5,
    position: 'Web dveloper',
    type: 'Contract',
    Skills: 'html, bootstrap,php',
    location: 'Boston',
    job_id: 1,
    Experience: '0-6 months',
    Description: 'Developer for websites and web apps',
    __v: 0 },
  { _id: 5b3a6151ccbdf81bcc5343e8,
    id: 5b3a6151ccbdf81bcc5343e7,
    position: 'Data analyst',
    type: 'contract',
    Skills: 'big data, hadoop,python',
    location: 'boston',
    job_id: 2,
    Experience: '1yr',
    Description: 'for analysing incoming data',
    __v: 0 },
  { _id: 5b3a6207ccbdf81bcc5343ea,
    id: 5b3a6207ccbdf81bcc5343e9,
    position: 'Content Writer',
    type: 'Permanent',
    Skills: 'Technical wirtting,Custmer engagement',
    location: 'new jersey',
    job_id: 3,
    Experience: '0-6 months',
    Description: 'for writting website content',
    __v: 0 },
  { _id: 5b3a62c4ccbdf81bcc5343ec,
    id: 5b3a62c4ccbdf81bcc5343eb,
    position: 'node js specialist',
    type: 'Permanent',
    Skills: 'node js ,express js , mean stack',
    location: 'boston',
    job_id: 4,
    Experience: '1yr',
    Description: 'for the web apps',
    __v: 0 },
  { _id: 5b3a6362ccbdf81bcc5343ee,
    id: 5b3a6362ccbdf81bcc5343ed,
    position: 'database expert',
    type: 'temporary',
    Skills: 'sql , no sql, mysql,sql server,mongo db',
    location: 'boston',
    job_id: 5,
    Experience: '2 yrs',
    Description: 'for desinging and maintaing databases',
    __v: 0 },
  { _id: 5b3a8639c8323b2cfc179969,
    id: 5b3a8639c8323b2cfc179968,
    position: 'Social media manager',
    type: 'Permanent',
    Skills: 'Social media marketing,Digital marketing',
    location: 'Boston',
    job_id: 4,
    Experience: '1yr',
    Description: 'For managing company socail media accounts',
    __v: 0 }

我已经浏览了 Redis 官方文档,但我一无所获。谁能指导我可以使用什么结构来存储以及如何在表中检索这些数据?

4

2 回答 2

1

您可以用来存储数据的替代方案之一是Redis 哈希数据结构。使用 Redis Hash 结构,您可以使用 id 作为键存储实体,然后使用HMSET 命令将剩余字段映射到 Redis Hash 。

Node.js 的推荐客户端是npm Redis 包。这将提供与 Redis 交互所需的所有功能。

最终,您的查询模式将为您的数据确定最佳结构。使用散列是解决问题的一种非常基本的实体映射方法,但它可能不是构造数据的最佳方法。根据您计划如何使用数据,可能有更有效的方法来构建数据。

于 2018-07-09T23:58:45.073 回答
-1

Redis 没有直接提供那么多结构,但是有分层库可以提供。我正在尝试使用 Walrus,一个 Python 库,它在 Redis 上提供了该功能。

于 2018-07-07T00:45:33.230 回答