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


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

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


在下文中一共展示了capitalize函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: getTypeName

 public getTypeName(input: IGQLType, args: RelatedGeneratorArgs) {
   const field = args.relatedField.relatedField as IGQLField
   return `${input.name}UpdateWithout${capitalize(field.name)}DataInput`
 }
開發者ID:dhruvcodeword,項目名稱:prisma,代碼行數:4,代碼來源:modelUpdateWithoutRelatedDataInputGenerator.ts

示例3: capitalize

    const types = typeCandidates.map(tc => {
      const name = capitalize(tc.name)
      const directives: IDirectiveInfo[] = [{
        name: 'pgTable',
        arguments: {
          name: `"${tc.name}"`
        }
      }]

      const fields: IGQLField[] = tc.columns.map(column => {
        
        const directives: IDirectiveInfo[] = []

        if(column.isPrimaryKey && column.name !== 'id') {
          directives.push({
            name: "pgColumn",
            arguments: {
              name: `"${column.name}"`
            }
          })
        }

        // TODO: Remove magic AUTO INCREMENT constant. 
        const defaultValue = column.defaultValue && column.defaultValue.trim() !== '[AUTO INCREMENT]' ? column.defaultValue : null
        const isUnique = column.isUnique

        return {
          name: column.isPrimaryKey ? 'id' : column.name,
          type: column.typeIdentifier || '<Unknown>',
          defaultValue, 
          isId: column.isPrimaryKey, 
          isList: false,
          isReadOnly: false,
          // TODO: We should turn of isRequired in case of auto-increment. 
          isRequired: !column.nullable,
          isUnique: column.isUnique,
          relatedField: null,
          relationName: null,
          directives,
          comments: column.comment === null ? [] : [{
            isError: true,
            text: column.comment
          }]
        } as IGQLField
      })

      const inlineRelations = tc.relations.filter(relation => {
        return relation.source_table === tc.name
      })
      const inlineRelationFields = inlineRelations.map(relation => {
        const ambiguousRelations = tc.relations.filter(innerRelation => innerRelation.source_table === relation.source_table && innerRelation.target_table === relation.target_table)
        const remoteColumns = _.intersectionWith(
          tc.columns,
          ambiguousRelations,
          (a, b) => a.name === b.source_column
        )
        
        const selfAmbiguousRelations = ambiguousRelations.filter(relation => relation.source_table === relation.target_table)
        const selfRemoteColumns = _.intersectionWith(
          tc.columns,
          selfAmbiguousRelations,
          (a, b) => a.name === b.source_column
        )

        const relationName = plural(relation.source_table) + '_' + plural(this.removeIdSuffix(relation.source_column))

        const directives: IDirectiveInfo[] = [{
          name: "pgRelation",
          arguments: {
            column: `"${relation.source_column}"`
          }
        }]

        const isAmbigous = ambiguousRelations.length > 1 && remoteColumns && remoteColumns.length > 0 ||
                         selfAmbiguousRelations.length > 0 && selfRemoteColumns && selfRemoteColumns.length > 0  

        return {
          name: this.removeIdSuffix(relation.source_column),
          type: capitalize(relation.target_table),
          isReadOnly: false,
          isRequired: false,
          isId: false,
          isUnique: false,
          defaultValue: null,
          isList: false,
          relatedField: null, // TODO: Find and link related field, if possible.
          relationName: isAmbigous ? camelCase(relationName) : null,
          directives
        } as IGQLField
      })

      const relationTables = joinTables.reduce((relations, joinTable) => {
        if (joinTable.relations.some(relation => relation.target_table === tc.name)) {
          return relations.concat(joinTable.relations.filter(relation => relation.target_table !== tc.name))
        } else {
          return relations
        }
      }, [] as TableRelation[])

      const relations = tc.relations.filter(relation => {
//.........這裏部分代碼省略.........
開發者ID:dhruvcodeword,項目名稱:prisma,代碼行數:101,代碼來源:postgresIntrospectionResult.ts

示例4: getTypeName

 public getTypeName(input: IGQLType, args: RelatedGeneratorArgs) {
   const field = args.relatedField.relatedField as IGQLField
   return `${input.name}UpsertWithWhereUniqueWithout${capitalize(
     field.name,
   )}Input`
 }
開發者ID:dhruvcodeword,項目名稱:prisma,代碼行數:6,代碼來源:modelUpsertWithWhereUniqueWithoutRelatedInputGenerator.ts

示例5: getTypeName

 public getTypeName(input: IGQLType, args: RelatedGeneratorArgs) {
   const field = (args.relatedField.relatedField as IGQLField)
   return `${input.name}UpdateOneRequiredWithout${capitalize(field.name)}Input`
 }
開發者ID:dhruvcodeword,項目名稱:prisma,代碼行數:4,代碼來源:modelUpdateOneRequiredWithoutRelatedInputGenerator.ts


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