Keystone JS , what field type we can you on saving an array of objects

戏子无情 提交于 2019-12-20 05:37:49

问题


In my program I generated an array of objects which is the ImageData , Now I want to save that data to mongo Db , I have no problem with other Keys except the ImageData key because I dont know what field type to use to be able to insert those data below which are an array of objects . What field type in keystone we could use to save those array of object example below ?. Thank you.

Data Model , this is the model , I tried using Text array but it does not seem to work.

Data.add({
    name: { type: String, required: false },
    Type: { type: Types.Select, options: 'New, Used,', index: true },
    ImageData: { type: Types.TextArray },
    content: {
        brief: { type: Types.Html, wysiwyg: true, height: 150 },
        extended: { type: Types.Html, wysiwyg: true, height: 400 },
    },
});

JSON Data that I need to save

  ImageData :  [ 
       { 
          "Uri":"Test.com",
          "Hash":"42e04950d6f11cd5350e3179083c7c7f",
          "Path":"/public/server/img/de29d68ab3594032bef70ead0b0d8fc2.jpg"
       },
       { 
          "Uri":"Test.com",
          "Hash":"42e04950d6f11cd5350e3179083c7c7f",
          "Path":"/public/server/img/de29d68ab3594032bef70ead0b0d8fc2.jpg"
       }
    ]

来源:https://stackoverflow.com/questions/57903062/keystone-js-what-field-type-we-can-you-on-saving-an-array-of-objects

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!