本文整理匯總了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)
//.........這裏部分代碼省略.........