将图像路径数组存储在indexedDB中

时间:2019-06-06 13:11:08

标签: reactjs electron indexeddb

尝试将具有图像路径数组的对象存储在indexedDB中,但该数组未存储。它始终保持空白。

我正在将React js与电子生成器一起用于桌面应用程序,并将indexedDB用作数据库。使用npm模块react-indexed-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"

0 个答案:

没有答案