어서와반가워
어서와반가워

Reputation: 1

What can I do? sequelize isnull

[table] USER_INFO

user_id  |  user_name
a123     |  facebook
b123     |  google
c123     |  NULL

[query]

select isnull(user_name, user_id) as user_name from USER_INFO

[result]

user_name
facebook
google
c123

[sequelize] ???????

User.findAll({attributes: [
    user_id
    ,user_name
 ]
});

I want the same result, query = sequelize..

Upvotes: 0

Views: 316

Answers (1)

Bruno Santi
Bruno Santi

Reputation: 192

Try using where operators:

User.findAll({where:{
    user_name:{[Op.ne]:null}
},{attributes: [user_id,user_name]
}});

Upvotes: 1

Related Questions