alyx
alyx

Reputation: 2733

Sequelize: Invalid value Symbol(col) in include query

Getting this error:

Error: Invalid value { [Symbol(col)]: 'user.profile_photo' }

With this Sequelize query:

const users = await db.users.findAll({
    where: {
      profile_photo: { [Op.ne]: null },
    },
    include: [
      {
        model: db.document,
        where: { 
          path: {[Op.not]: [
            { [Op.col]: 'user.profile_photo' }
          ]},
        }
      }
    ],
});

I've also tried with users.profile_photo.

I'm trying to not include users that have document.path which equal user.profile_photo. Is there an issue with the query construction?

Upvotes: 0

Views: 1176

Answers (1)

roychri
roychri

Reputation: 2936

Try this:

path: {
    [Op.not]: {
        [Op.col]: 'users.profile_photo'
    }
}

I know older version of sequelize would allow this:

path: {[Op.not]: '$users.profile_photo$'}

I have not tested this but it should be something like that or close.

Upvotes: 1

Related Questions