Вставка в таблицу с массивом json и текстовым массивом приводит к «отсутствующему значению измерения - PullRequest
0 голосов
/ 27 сентября 2018

Это моя модель knex:

static get jsonSchema() {
    return {
        type: 'object',
        required: [
            'title', 'companyId', 'city',
            'languages', 'jobTitle', 'channels',
            'salary', 'jobCommitmentType', 'callToAction'
        ],
        properties: {
            id: {type: 'string', format: 'uuid'},
            title: {type: 'string'},
            companyId: {type: 'string', format: 'uuid'},
            city: {type: 'string', enum: enums.cities },
            languages: {type: 'array', items: { type: 'string', enum: enums.languages }},
            jobTitle: {type: 'string'},
            channels: { type: 'array', items: { type: 'string', enum: enums.campaignChannels }},
            salary: {type: 'string'},
            benefits: {type: ['string', 'null']},
            jobCommitmentType: {type: 'string', enum: enums.jobCommitmentTypes},
            documents: {type: ['string', 'null']},
            requirements: {
                type: 'array',
                items: {
                    type: 'object',
                    required: ['requirement','hardRequirement'],
                    properties: {
                        requirement: {type: 'string', enum: enums.jobRequirements},
                        hardRequirement: {type: 'boolean'}
                    }
                }
            },
            contactPhoneNumber: {type: ['string', 'null']},
            callToAction: {type: 'string', enum: enums.campaignCallToActions},
            address: {type: ['string', 'null']},
            pinCode: {type: ['string', 'null']},
            timings: {type: ['string', 'null']},
            googleMapsLink: {type: ['string', 'null']},
            profilePictureUrl: {type: ['string', 'null']},
        },
        if: {
            properties: {
                callToAction: {
                    pattern: enums.campaignCallToActionNames.CALL_US
                }
            }
        },
        then: {
            required: ['contactPhoneNumber']
        },
        else: {
            if: {
                properties: {
                    callToAction: {
                        pattern: enums.campaignCallToActionNames.WALK_IN
                    }
                }
            },
            then: {
                required: ['contactPhoneNumber', 'address', 'pinCode', 'timings', 'googleMapsLink']
            }
        }
    };
}

Я получаю эту ошибку при вставке даты в таблицу (возражение против postgres db).

"error: missing dimension value
    at Connection.parseE (/home/nitish/vahan/JobFinder/node_modules/pg/lib/connection.js:539:11)
    at Connection.parseMessage (/home/nitish/vahan/JobFinder/node_modules/pg/lib/connection.js:366:17)
    at Socket.<anonymous> (/home/nitish/vahan/JobFinder/node_modules/pg/lib/connection.js:105:22)
    at Socket.emit (events.js:182:13)
    at addChunk (_stream_readable.js:277:12)
    at readableAddChunk (_stream_readable.js:262:11)
    at Socket.Readable.push (_stream_readable.js:217:10)
    at TCP.onread (net.js:638:20)

Похоже, этоиз-за поля требований, которое является массивом json, но я не уверен.

...