當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript prisma-yml.PrismaDefinitionClass類代碼示例

本文整理匯總了TypeScript中prisma-yml.PrismaDefinitionClass的典型用法代碼示例。如果您正苦於以下問題:TypeScript PrismaDefinitionClass類的具體用法?TypeScript PrismaDefinitionClass怎麽用?TypeScript PrismaDefinitionClass使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了PrismaDefinitionClass類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: constructor

  constructor(definition: PrismaDefinitionClass) {
    this.cluster = definition.getCluster()!
    this.definition = definition

    if (this.cluster.shared) {
      throw new Error(
        `Cannot introspect demo server. Please use introspection on your self-hosted server.`,
      )
    }
  }
開發者ID:dhruvcodeword,項目名稱:prisma,代碼行數:10,代碼來源:prismaDBClient.ts

示例2: connect

  async connect() {
    await this.cluster
      .request(
        `mutation($input: AddProjectInput!) {
      addProject(input: $input) {
        clientMutationId
      }
    }`,
        {
          input: {
            name: SERVICE_NAME,
            stage: SERVICE_STAGE,
            secrets: [SERVICE_SECRET],
          },
        },
      )
      .then(res => res.json())

    const endpoint = this.cluster.getApiEndpoint(SERVICE_NAME, SERVICE_STAGE)
    const secretsBackup = this.definition.secrets
    this.definition.secrets = [SERVICE_SECRET]
    const token = this.definition.getToken(SERVICE_NAME, SERVICE_STAGE)
    this.definition.secrets = secretsBackup
    this.client = new GraphQLClient(endpoint, {
      headers: token
        ? {
            Authorization: `Bearer ${token}`,
          }
        : {},
    })
  }
開發者ID:dhruvcodeword,項目名稱:prisma,代碼行數:31,代碼來源:prismaDBClient.ts

示例3: seed

  async seed(
    serviceName: string,
    stageName: string,
    reset: boolean = false,
    workspaceSlug?: string,
  ) {
    const seed = this.definition.definition!.seed
    if (!seed) {
      throw new Error(
        `In order to seed, you need to provide a "seed" property in your prisma.yml`,
      )
    }
    if (seed.import && seed.run) {
      throw new Error(
        `Please provider either seed.import or seed.run but not both at the same time`,
      )
    }

    if (seed.import) {
      const source = path.join(this.config.definitionDir, seed.import)

      debug(source)

      if (!source.endsWith('.zip') && !source.endsWith('.graphql')) {
        throw new Error(`Source must end with .zip or .graphql`)
      }

      if (!fs.pathExistsSync(source)) {
        throw new Error(`Path ${source} does not exist`)
      }

      const token = this.definition.getToken(serviceName, stageName)

      if (reset) {
        await this.reset(serviceName, stageName)
      }

      if (source.endsWith('.zip')) {
        await this.import(source, serviceName, stageName, token, workspaceSlug)
      } else if (source.endsWith('.graphql')) {
        await this.executeQuery(
          source,
          serviceName,
          stageName,
          token,
          workspaceSlug,
        )
      }
    }

    if (seed.run) {
      if (reset) {
        await this.reset(serviceName, stageName)
      }

      await this.run(seed.run)
    }
  }
開發者ID:ahmb84,項目名稱:prisma,代碼行數:58,代碼來源:Seeder.ts

示例4: reset

 async reset(serviceName, stageName) {
   const before = Date.now()
   this.out.action.start(
     `Resetting ${chalk.bold(`${serviceName}@${stageName}`)}`,
   )
   await this.client.reset(
     serviceName,
     stageName,
     this.definition.getToken(serviceName, stageName),
   )
   this.out.action.stop(chalk.cyan(`${Date.now() - before}ms`))
 }
開發者ID:ahmb84,項目名稱:prisma,代碼行數:12,代碼來源:Seeder.ts

示例5: import

 private async import(
   source: string,
   serviceName: string,
   stage: string,
   token?: string,
   workspaceSlug?: string,
 ) {
   await this.definition.load({})
   const typesString = this.definition.typesString!
   const importer = new Importer(
     source,
     typesString,
     this.client,
     this.out,
     this.config,
   )
   await importer.upload(serviceName, stage, token, workspaceSlug)
 }
開發者ID:ahmb84,項目名稱:prisma,代碼行數:18,代碼來源:Seeder.ts


注:本文中的prisma-yml.PrismaDefinitionClass類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。