我收到错误消息“ ER_WRONG_VALUE_COUNT_ON_ROW:列数与第1行的值数不匹配”
使用sails-mysql但idk我的代码有什么问题
我的管理员模型:
const CryptoJS = require('crypto-js'), _ = require('lodash')
module.exports = {
attributes: {
username: 'string',
password: 'string',
email: 'string',
token: 'string'
},
beforeCreate(val, proceed) {
sails.helpers.passwords.hashPassword(val.password).exec((err, hashed) => {
if (err) return proceed(err)
val.password = hashed
val.token = CryptoJS.SHA1(val.username)
return proceed()
})
},
beforeUpdate(val, proceed) {
if (_.isEmpty(val.password)) return proceed()
sails.helpers.passwords.hashPassword(val.password).exec((err, hashed) => {
if (err) return proceed(err)
val.password = hashed
return proceed()
})
}
};
和我的配置引导程序:
const async = require('async')
module.exports.bootstrap = function(done) {
let username = 'admin', password = 'admin123', email = 'admin@joksurabaya.com'
async.waterfall([
function (cb) {
Admin.create({
username: username,
password: password,
email: email
}).exec((err) => {
if (err) return cb(err)
return cb()
})
}
], (err) => {
if (err) return done(err)
return done()
})
};
任何解决方案吗?