本文整理汇总了TypeScript中klay-core.ModelContext.integer方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ModelContext.integer方法的具体用法?TypeScript ModelContext.integer怎么用?TypeScript ModelContext.integer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类klay-core.ModelContext
的用法示例。
在下文中一共展示了ModelContext.integer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: beforeEach
beforeEach(() => {
const context = new ModelContext()
context.use(new DatabaseExtension())
model = context
.object()
.children({
id: context.integerId(),
x: context
.integer()
.constrain({type: 'unique'})
.required(),
y: context
.integer()
.constrain({type: 'immutable'})
.automanage({event: 'create', supplyWith: v => v.setValue(1)}),
z: context.integer().automanage({event: '*', supplyWith: v => v.setValue(2)}),
})
.constrain({
type: 'custom',
meta: {
evaluate(data) {
if (data.record.x > 100) {
throw new Error('x is too big')
}
},
},
})
executorMinimal = {
transaction(f) {
transaction = {}
return f(transaction)
},
count(query) {
return executorMinimal.find(query).length
},
find(query) {
return _.filter(executorData, query.where)
},
findById(id) {
return _.filter(executorData, {id})[0]
},
save(object) {
if (!object.id) {
object.id = executorData.length ? _.maxBy(executorData, 'id').id + 1 : 1
}
executorMinimal.destroyById(object.id)
executorData.push(object)
return object
},
destroyById(id) {
executorData = executorData.filter(item => item.id !== id)
},
}
executor = new Executor(model, executorMinimal)
executorData = []
})