本文整理汇总了TypeScript中prisma-cli-engine.Client.upload方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Client.upload方法的具体用法?TypeScript Client.upload怎么用?TypeScript Client.upload使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类prisma-cli-engine.Client
的用法示例。
在下文中一共展示了Client.upload方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: upload
async upload(
serviceName: string,
stage: string,
token?: string,
workspaceSlug?: string,
) {
try {
if (!this.isDir) {
this.unzip()
}
let before = Date.now()
this.out.action.start('Validating data')
const files = await this.getFiles()
this.validateFiles(files)
this.out.action.stop(chalk.cyan(`${Date.now() - before}ms`))
before = Date.now()
this.out.log('\nUploading nodes...')
const state = this.getState()
for (const fileName of files.nodes) {
const n = this.getNumber(fileName)
if (state.nodes >= n) {
this.out.log(`Skipping file ${fileName} (already imported)`)
continue
}
const file = fs.readFileSync(fileName, 'utf-8')
const json = JSON.parse(file)
const result = await this.client.upload(
serviceName,
stage,
file,
token,
workspaceSlug,
)
this.checkForErrors(result)
if (result.length > 0) {
this.out.log(this.out.getStyledJSON(result))
this.out.exit(1)
}
state.nodes = n
this.saveState(state)
}
this.out.log(
'Uploading nodes done ' + chalk.cyan(`${Date.now() - before}ms`),
)
before = Date.now()
this.out.log('\nUploading lists')
for (const fileName of files.lists) {
const n = this.getNumber(fileName)
if (state.lists >= n) {
this.out.log(`Skipping file ${fileName} (already imported)`)
continue
}
const file = fs.readFileSync(fileName, 'utf-8')
const json = JSON.parse(file)
const result = await this.client.upload(
serviceName,
stage,
file,
token,
workspaceSlug,
)
this.checkForErrors(result)
if (result.length > 0) {
this.out.log(this.out.getStyledJSON(result))
this.out.exit(1)
}
state.lists = n
this.saveState(state)
}
this.out.log(
'Uploading lists done ' + chalk.cyan(`${Date.now() - before}ms`),
)
before = Date.now()
this.out.log('\nUploading relations')
for (const fileName of files.relations) {
const n = this.getNumber(fileName)
if (state.relations >= n) {
this.out.log(`Skipping file ${fileName} (already imported)`)
continue
}
const file = fs.readFileSync(fileName, 'utf-8')
const json = JSON.parse(file)
const result = await this.client.upload(
serviceName,
stage,
file,
token,
workspaceSlug,
)
this.checkForErrors(result)
if (result.length > 0) {
this.out.log(this.out.getStyledJSON(result))
this.out.exit(1)
}
state.relations = n
this.saveState(state)
}
this.saveState(defaultState)
//.........这里部分代码省略.........