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


TypeScript prisma-datamodel.plural函數代碼示例

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


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

示例1: plural

      const relationFields = relations.map(relation => {
        const ambiguousRelations = tc.relations.filter(innerRelation => innerRelation.source_table === relation.source_table && innerRelation.target_table === relation.target_table)
        const fieldName = ambiguousRelations.length > 1 
                ? plural(relation.source_table) + '_' + plural(
                  this.removeIdSuffix(relation.source_column)
                )
                : plural(relation.source_table)

        const selfAmbiguousRelations = ambiguousRelations.filter(relation => relation.source_table === relation.target_table)

        const isAmbigous = ambiguousRelations.length > 1  || selfAmbiguousRelations.length > 0

        return {
          name: fieldName, 
          type: capitalize(relation.source_table), 
          isRequired: true,
          isReadOnly: false,
          isId: false,
          isList: true, 
          isUnique: false,
          defaultValue: null,
          relatedField: null, // TODO
          relationName: isAmbigous ? camelCase(fieldName) : null
        } as IGQLField
      })
開發者ID:dhruvcodeword,項目名稱:prisma,代碼行數:25,代碼來源:postgresIntrospectionResult.ts

示例2: generateManyQueryField

  private generateManyQueryField(model: IGQLType) {
    const fields = {} as GraphQLFieldConfigMap<any, any>

    fields[camelCase(plural(model.name))] = {
      type: new GraphQLNonNull(new GraphQLList(this.generators.model.generate(model, {}))),
      args: this.generators.manyQueryArguments.generate(model, {})
    }
    fields[`${camelCase(plural(model.name))}Connection`] = {
      type: new GraphQLNonNull(this.generators.modelConnection.generate(model, {})),
      args: this.generators.manyQueryArguments.generate(model, {})
    }

    return fields
  }
開發者ID:dhruvcodeword,項目名稱:prisma,代碼行數:14,代碼來源:queryGenerator.ts

示例3: generateDeleteManyField

  private generateDeleteManyField(model: IGQLType) {
    const fields = {} as GraphQLFieldConfigMap<null, null>

    if (this.generators.modelWhereInput.wouldBeEmpty(model, {})) {
      return fields
    }

    fields[`deleteMany${plural(model.name)}`] = {
      type: new GraphQLNonNull(this.generators.batchPayload.generate(null, {})),
      args: {
        where: { type: this.generators.modelWhereInput.generate(model, {}) },
      },
    }

    return fields
  }
開發者ID:dhruvcodeword,項目名稱:prisma,代碼行數:16,代碼來源:mutationGenerator.ts


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