本文整理汇总了TypeScript中klay-kiln.IKiln.build方法的典型用法代码示例。如果您正苦于以下问题:TypeScript IKiln.build方法的具体用法?TypeScript IKiln.build怎么用?TypeScript IKiln.build使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类klay-kiln.IKiln
的用法示例。
在下文中一共展示了IKiln.build方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: forEach
forEach(routerMap, (routerOrOptions, prefix) => {
let subRouter = routerOrOptions as IRouter
if (!Array.isArray(routerOrOptions.routes)) {
const routerOptions = routerOrOptions as IRouterOptions
if (routerOptions.modelName) {
const kilnModel = models[routerOptions.modelName]
const databaseExtension = routerOptions.databaseExtension || DEFAULT_DATABASE_EXTENSION
const executor = kiln.build<IDatabaseExecutor>(routerOptions.modelName, databaseExtension)
subRouter = createRouter(routerOptions, kilnModel, executor)
} else {
subRouter = createRouter(routerOptions)
}
}
router.use(prefix, subRouter.router)
subRouter.routes.forEach(route => {
routes.push({...route, path: `${prefix}${route.path}`})
})
})
示例2: addForeignKeys
export function addForeignKeys(
modelInProgress: Sequelize.DefineAttributes,
model: IModel,
kiln: IKiln,
): void {
const constraints = model.spec.db!.constrain
for (const constraint of constraints) {
if (constraint.type !== ConstraintType.Reference) {
continue
}
assert.ok(constraint.properties.length === 1, 'foreign key must be single field')
const fkName = getFlattenedPath(constraint.properties[0])
const fkDefinition = modelInProgress[fkName] as Sequelize.DefineAttributeColumnOptions
const sqlExecutor = kiln.build<ISQLExecutor>(constraint.meta.referencedModel!, SQL_EXECUTOR)
fkDefinition.references = {
key: getPrimaryKeyField(sqlExecutor.kilnModel.model),
model: sqlExecutor.sequelizeModel,
}
}
}