问题
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