console.log print:
Missing where attribute in the options parameter
what"s the problem?
model/user.js
module.exports = app => {
const {
STRING,
INTEGER,
DATE,
BOOLEAN
} = app.Sequelize;
return app.model.define("user", {
avatar: STRING(30),//
username: STRING(30),//
nickname: STRING(32),//
age: DATE,//
sex: STRING(8),//
password: STRING(255),//
email: STRING(32),//
mobile: STRING(32),//
wechat_name: STRING(32),//
role_id: INTEGER(8),//
count: INTEGER,//
last_sign_in_at: DATE,//
last_login_ip: STRING(32),//IP
status: INTEGER(1),//
});
};
service/login.js
async logout(id, ipAt) {
const { model } = this.ctx;
const logoutByUser = await model.User.update({
attributes:["id","last_login_ip","ast_sign_in_at"],
where: {
id: id,
last_login_ip: ipAt,
last_sign_in_at:new Date()
}
})
return logoutByUser
}
controller/login.js
async logout() {
const { app, ctx } = this;
if(ctx.session.isLogin){
const logoutLog = await ctx.service.login.logout(ctx.session.user.data.id,ctx.request.ip);
}
ctx.session.user = null
ctx.session.isLogin = false
let data = {
code: 200,
msg: "!",
}
ctx.response.body = data;
}