user.setShooter将在这里做什么?
return sequelize.transaction(function (t) {
// chain all your queries here. make sure you return them. <br>
return User.create({<br>
firstName: 'Abraham',<br>
lastName: 'Lincoln'<br>
}, {transaction: t}).then(function (user) {<br>
return user.setShooter({<br>
firstName: 'John',<br>
lastName: 'Boothe'<br>
}, {transaction: t});<br>
});<br>
<br>
}).then(function (result) {<br>
// Transaction has been committed<br>
// result is whatever the result of the promise chain returned to the transaction callback<br>
}).catch(function (err) {<br>
// Transaction has been rolled back<br>
// err is whatever rejected the promise chain returned to the transaction callback<br>
});<br>
答案 0 :(得分:0)
setShooter只是某些Sequelize模型类中的函数
例如
// unit test code;
describe('Check if endpoint are reachable', () => {
before(function(done) {
// call /router to generate session;
AGENT.get('/router')
.query(clientData)
.expect(302)
.end((err, res) => {
if (!err) {
done()
} else {
done(err);
}
});
});
// .......
});
// controller code where the session is set;
// .....
req.session.clientData = clientData;
// ....