最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - mongoose with dynamic properties - Stack Overflow

programmeradmin1浏览0评论

pretty new to mongoose, I have my dropdown options in the structure below. This way the overall group holds the collection of dropdown options... a task page would have options for "status", "result", a user page have "typePhone", etc.

what is the correct way build a Schema for such a structure? Thinking I'm going to have to transform it to the below somehow if I can't store as is.

{
  "task": {
    "status": [
      {
        "key": 0,
        "text": "pending"
      },
      {
        "key": 1,
        "text": "in progress"
      },
      {
        "key": 2,
        "text": "completed"
      },
      {
        "key": 3,
        "text": "cancelled"
      }
    ],
    "result": [
      {
        "key": 0,
        "text": ""
      },
      {
        "key": 1,
        "text": "good"
      },
      {
        "key": 2,
        "text": "not good"
      },
      {
        "key": 3,
        "text": "who knows"
      }
    ]
  },
  "user": {
    "typePhone": [
      {
        "key": "1",
        "text": "Landline"
      },
      {
        "key": "2",
        "text": "Mobile"
      },
      {
        "key": "3",
        "text": "Other"
      }      
    ]
}
发布评论

评论列表(0)

  1. 暂无评论