Friday, 12 May 2017

Sequelize query: How to find column, "where:" the column value is not equal to any value in an array

db.Matches.findAll({
    where: { WLID: { $ne: currentUser } },

    attributes: ['GLID']


}).then(function(data) {
    // console.log(data);
    // console.log(data);

    var GLIDsToPass = [];

    data.forEach((dataItem) => {

        GLIDsToPass.push(dataItem);

        console.log(dataItem.get({
            plain: true
        }));
    });

});

db.user.findAll({

    where: {
        id: {
            $ne: req.user.id
        }
    },
    where: {
        id: {
            $ne: "WHAT DO I PUT HERE"
        }
    },...

I have two tables, user and Matches. I am making a query to findAll values in a column, in the Matches table. Then I want to query the user table and findAll rows that don't have an id equal to any value queried from the match table.

I have to values from the Matches table stored in an array. how can I say:

 where: {
    id: {
        $ne: "any value in GLIDsToPass array"
    }
},



via Mike

No comments:

Post a Comment