本文整理汇总了TypeScript中bluebird.using函数的典型用法代码示例。如果您正苦于以下问题:TypeScript using函数的具体用法?TypeScript using怎么用?TypeScript using使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了using函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
return function(
clientName: string,
config: Config,
journalTable: string,
migrations: Migration[]
) {
let client = requireClient(clientName);
return Promise.using(useConnection(client, config), db =>
client.ensureJournal(db, journalTable)
.then(() => client.beginTransaction(db))
.return(migrations)
.each((migration: Migration) =>
readSQL(migration).then(sql =>
client.runMigrationSQL(db, sql)
.then(() => client.appendJournal(db, journalTable, {
operation: operation,
migrationID: migration.id,
migrationName: migration.name
}))
)
)
.finally(() => client.rollbackTransaction(db))
.then(() => client.readJournal(db, journalTable))
);
};
示例2: function
desc.value = function(...args: any[]) {
debug('START @transactional');
return Bluebird.using(new Transaction().begin(), t => {
if (args[args.length] !== undefined) throw new Error('last parameter must be a Transaciton object.');
args[args.length] = t;
return originalMethod.apply(this, args);
});
};
示例3: readJournal
export function readJournal(
clientName: string, config: Config, journalTable: string
) {
let client = requireClient(clientName);
return Promise.using(useConnection(client, config), (db) =>
client.ensureJournal(db, journalTable)
.then(() => client.readJournal(db, journalTable))
);
}