Postgresql Sequelize:查询返回字符串数组作为字符串,而不是字符串数组?

Postgresql Sequelize:查询返回字符串数组作为字符串,而不是字符串数组?,postgresql,sequelize.js,Postgresql,Sequelize.js,我有一个Postgres表,表中有一个名为specialties的字段。该字段定义为: const myModel = db.define('my_model', { id: {type: Sequelize.INTEGER, primaryKey: true, autoIncrement: true}, createdAt: {type: Sequelize.DATE}, updatedAt: {type: Sequelize.DATE}, jobName: {

我有一个Postgres表,表中有一个名为
specialties
的字段。该字段定义为:

const myModel = db.define('my_model', {
    id: {type: Sequelize.INTEGER, primaryKey: true, autoIncrement: true},
    createdAt: {type: Sequelize.DATE},
    updatedAt: {type: Sequelize.DATE},
    jobName: {type: Sequelize.STRING},
    specialties: {type: Sequelize.ARRAY(Sequelize.STRING)}
});
我通过导入带有以下格式字符串的.csv文件,填充了
specialties
字段的内容:

["mySpeciality_1", "mySpeciality_2", "mySpeciality_3"]
我是这样查询表的:

return Promise.resolve()
    .then(() => {
        let specialties = connectors.myModel.findAll({
            where: {'jobName': jobName}
        }).then((specialties) => specialties.map((item) => item.dataValues));
        return specialties;
    })
    .then(([specialties, metaData]) => {
        [.....]
specialties
作为一个对象返回,其字段名为
specialties
,其中包含一个字符串,如下所示:

["mySpeciality_1", "mySpeciality_2", "mySpeciality_3"]
我是否使用错误格式的字符串导入了字符串数组字段
specialties
?或者,我是否需要以不同的方式编写sequelize查询

找到了

首先,我将字段定义为字符变化[]。这似乎不起作用。它似乎想成为文本[]。以下是Valentina postgres客户端的外观:

我以以下格式从.csv导入了字段:

 {mySpeciality_1, mySpeciality_2, mySpeciality_3}
下面是正在运行的sequelize查询:

return Promise.resolve()
    .then(() => {
        let theJob = connectors.myModel.findAll({
            where: {'jobName': jobName}
        }).then((theJob) => theJob.map((item) => item.dataValues));
        return theJob;
    })
    .then(([theJob, metaData]) => {
        let specialties = theJob.specialties;

反勾号是否用于模板文本(字符串的方括号部分)?1)反勾号仅用于格式化。.csv中是否应该有反勾号?2) 方括号不是字符串的一部分——它只是尝试使用某种语法,以便postgres字符串数组字段能够理解它们是字符串数组中的单个元素……我想既然文本是缩进的,就不需要反勾号了。