當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Sequelize.sync函數代碼示例

本文整理匯總了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));
	});
開發者ID:projectSHAI,項目名稱:expressgular2,代碼行數:8,代碼來源:index.ts

示例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();
        });
      })
開發者ID:lucasBertola,項目名稱:Turnkey,代碼行數:21,代碼來源:index.ts

示例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)
    }
}
開發者ID:lanarts,項目名稱:server,代碼行數:23,代碼來源:models-sql.ts

示例4:

 .then(function() { return sequelize.sync({force: true}) })
開發者ID:samuelneff,項目名稱:sequelize-learning,代碼行數:1,代碼來源:app.ts

示例5: retry

retry(3, 5000, () => db.sync()).then(() => {
開發者ID:CWSpear,項目名稱:name-game,代碼行數:1,代碼來源:index.ts

示例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();
}
開發者ID:hxjp,項目名稱:simekiri-bot,代碼行數:30,代碼來源:bot.ts

示例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
開發者ID:rymizuki,項目名稱:site-animechannel,代碼行數:21,代碼來源:db.ts

示例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)));
 });
開發者ID:hxjp,項目名稱:simekiri-bot,代碼行數:5,代碼來源:reminder.test.ts


注:本文中的Sequelize.sync函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。