简体   繁体   中英

Problem creating a mongoose schema from a JSON file

Is it possible to create this JSON file structure as a mongoose schema? mongoose doesn't offer an object type and I don't know how to implement it.

{
  "Mountainbike": {
    "Cross": {
      "size": [
        "395 mm",
        "440 mm",
        "480 mm",
        "535 mm"
      ],
      "color": [
        "Himmelblau",
        "Grasgrün",
        "Stahlgrau",
        "Weinrot"
      ],
      "brake": [
        "Shimano Deore BRM6000",
        "Shimano Deore BRM7000",
        "Shimano RX810 1x11"
      ],
}
}
}

In mongoose this will be look like:

 new mongoose.Schema({ Mountainbike: { type: { Cross: { type: { size: [String], color: [String], brake: [String] } } } } })

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM