我了解下面的代码是在数据库中创建NEW
表并将其称为User
,然后向其中添加数据。
我在我的数据中已存在表User
,我只想做一个与此表同步的模型,我该怎么办?
var Sequelize = require('sequelize');
var sequelize = new Sequelize('database', 'username', 'password');
var User = sequelize.define('user', {
username: Sequelize.STRING,
birthday: Sequelize.DATE
});
sequelize.sync().then(function() {
return User.create({
username: 'janedoe',
birthday: new Date(1980, 6, 20)
});
}).then(function(jane) {
console.log(jane.get({
plain: true
}));
});
答案 0 :(得分:0)
看起来唯一的选择就是写$fourDaysAgo = new DateTime('-4 days');
// some code for xml feed
$xmlDate = //(string) $item[$i]->date;
$date = new DateTime($xmlDate);
if($fourDaysAgo->format('Y-m-d') == $date->format('Y-m-d') ) {
echo 'Store in database';
}