本文整理汇总了TypeScript中Sequelize.sync函数的典型用法代码示例。如果您正苦于以下问题:TypeScript sync函数的具体用法?TypeScript sync怎么用?TypeScript sync使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sync函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
return Rx.Observable.create(observer => {
sequelize.sync().then(function() {
observer.next();
observer.complete();
}).catch(err => observer.error(err));
});
示例2: recursive
recursive(__dirname ,function (err:any, files:any) {
for(var fileIndex = files.length-1 ; fileIndex >= 0 ; fileIndex--){
var file = files[fileIndex];
if( (file.indexOf(".") !== 0) && (file.indexOf("index.js") == -1) && (file !== "index.js") && file.slice(file.indexOf("."), file.length) === ".js"){
//todo replace all recurisivly
var newFile = file.replace(__dirname,".").replace("\\","/").replace("\\","/");
var split = newFile.split("/");
split[split.length -1] = capitalizeFirstLetter(split[split.length -1]);
newFile = split.join("/");
var model = require(newFile);
if("associate" in model){
model.associate();
}
}
}
sequelize.sync({ force: false }).then(function(){
resolve();
});
})
示例3: main
// Where
async function main() {
// await DB.sync({alter: true});
await DB.sync();
try {
const [gallanthor] = await Account.findOrCreate({
where: {name: 'Gallanthor'},
defaults: {
data: {
hasStarBesideName: true
}
}
});
console.log(gallanthor.toJSON());
// const allAccounts = await Account.findAll({where: {name: 'Gallanthor'}})
// console.log(allAccounts)
} catch (err) {
if (err.constructor === sequelize.ValidationError) {
console.log("WHAAAT")
}
console.log(err)
}
}
示例4:
.then(function() { return sequelize.sync({force: true}) })
示例5: retry
retry(3, 5000, () => db.sync()).then(() => {
示例6: Error
});
const bot = controller.spawn({
token,
incoming_webhook: {
url: 'https://hooks.slack.com/services/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'
}
})
.startRTM(function(err: any): void {
if (err) {
throw new Error(err);
}
});
const sequelize = new Sequelize(databaseUrl, {
dialect: 'mysql'
});
defineModels(sequelize);
sequelize.sync({force: !!options.force});
for (const conversationClass of ALL_CONVERSATIONS) {
let conversation;
if (conversationClass === Reminder) {
conversation = new Reminder(sequelize, bot, undefined, undefined, options['reminder-channel'] || undefined);
} else {
conversation = createConversation(conversationClass, sequelize, bot);
}
conversation.start();
}
示例7: Sequelize
import Sequelize from 'sequelize'
const database = process.env.MYSQL_DATABASE
const user = process.env.MYSQL_USER
const pass = process.env.MYSQL_PASSWORD
const db = new Sequelize(database, user, pass, {
host: 'mysql',
dialect: 'mysql',
define: {
charset: 'utf8',
collate: 'utf8_general_ci',
timestamps: true
},
})
db.sync((err) => {
console.error(err)
})
export default db
示例8: beforeEach
beforeEach(async function(): Promise<any> {
await sequelize.sync({force: true});
await Promise.all(USER_DATA.map(user => User.create(user)));
await Promise.all(SCHEDULE_DATA.map(schedule => Schedule.create(schedule)));
});