如何在续集中连接列?

far*_*afi 2 node.js sequelize.js

我正在使用sequelize 和node.js。我想将 PrimaryPractice 模型的列值相互连接。我怎么解决这个问题?这是我的代码:

ProviderPayer.findAll({
                  where: {
                      orgPayerId: {
                          [Op.in]: orgPayerIds
                      }
                  },
                  attributes: ["effective_date"],
                  include: [{
                          model: PayerTracks,
                          attributes: ["title"],
                          as: "payers",
                      },
                      {
                          model: User,
                          where: {
                              id: {[Op.in]: userIds},
                              deletedAt: null,
                              status: {[Op.ne]: STATUS.INACTIVE}
                          },
                          attributes: ["id"],
                          include: [
                              {
                                  model: PrimaryPractice,
                                  as: "primaryPractice",
                                  attributes: [
                                   "addressStreetPrimPract", 
                                   "addressStreet2PrimPract", 
                                   "addressCityPrimPract", 
                                   "addressStatePrimPract", 
                                   "addressZipPrimPract"]
                              }
                          ]
                      }

                  ]
              })
Run Code Online (Sandbox Code Playgroud)

Ana*_*oly 5

如果你的 DBMS 有类似CONCAT功能的东西,那么你可以尝试这样的事情:

attributes: [
  [
    sequelize.fn('CONCAT',
      sequelize.col('addressStreetPrimPract'), ', ', 
      sequelize.col('addressStreet2PrimPract'), ', ', 
      sequelize.col('addressCityPrimPract'), ', ', 
      sequelize.col('addressStatePrimPract'), ', ', 
      sequelize.col('addressZipPrimPract')
    ),
    'concatenated_fields_alias'
  ],
],
Run Code Online (Sandbox Code Playgroud)