• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript prisma-yml.PrismaDefinitionClass类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript prismjs.highlight函数代码示例发布时间:2022-05-25
下一篇:
TypeScript prisma-datamodel.SdlExpect类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap