本文整理匯總了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)));
});