Попытка сохранить объект в indexedDB с массивом путей к изображениям, но этот массив не сохраняется. Это всегда остается пустым.
Я использую реагирующий js с электронным компоновщиком для настольных приложений и использую indexedDB в качестве базы данных. использование модуля npm-index-index-DB для операций с базой данных.
addToDB(payload){
let propImg = payload.images
let floorImg= payload.floorImages
payload['propImgs'] = {path: propImg};
payload['floorImgs'] = {path: floorImg};
delete payload.images;
delete payload.floorImages;
console.log(payload, "in addtodb()")
this.db.add('property', payload)
.then(() => {
swal("Successfully!", "Your property has been listed successfully.", "success", {
buttons: {
"Another": true,
"Home": true,
},
}).then((value) => {
switch (value) {
case "Another":
window.location.reload();
break;
case "Home":
this.setState({toHome: true})
break;
default:
window.location.reload();
}
});
this.setState({isLoading:false});
// window.location.reload();
},error => {
console.log(error);
});
}
это моя полезная нагрузка для добавления в базу данных:
attributes: {area: {…}, stype: "Apartment", rooms: "2", buildingAge: "5 Years", bedrooms: "3", …}
currency: "USD"
description: "sd gsdfg tgfh dfg dfg dfg sd"
floorDescription: "asdf dgh dgjfdg df ghsfn gb"
**floorImages: ["xrdrPsq_E/floor/pasted image 0.png"]**
geoLocation: {type: "Point", coordinates: Array(2)}
**images: (4) ["xrdrPsq_E/SampleJPGImage_50kbmb.jpg", "xrdrPsq_E/SampleJPGImage_100kbmb.jpg", "xrdrPsq_E/SampleJPGImage_200kbmb.jpg", "xrdrPsq_E/SampleJPGImage_500kbmb.jpg"]**
location: {address: "saf s s", city: "sdg sdgs s", state: " sdfg sd ", zipcode: " sdfg sd fs", neighborhood: ""}
price: "1563"
status: "sale"
title: "saf asdf"
_id: "xrdrPsq_E"
и сохраненный объект:
attributes: {area: {…}, stype: "Apartment", rooms: "2", buildingAge: "5 Years", bedrooms: "3", …}
currency: "USD"
description: "sd gsdfg tgfh dfg dfg dfg sd"
floorDescription: "asdf dgh dgjfdg df ghsfn gb"
**floorImages: []**
geoLocation: {type: "Point", coordinates: Array(2)}
**images: []**
location: {address: "saf s s", city: "sdg sdgs s", state: " sdfg sd ", zipcode: " sdfg sd fs", neighborhood: ""}
price: "1563"
status: "sale"
title: "saf asdf"
_id: "xrdrPsq_E"