【问题标题】:GraphQL enum to DB integers instead of stringsGraphQL 枚举到 DB 整数而不是字符串
【发布时间】:2018-09-11 03:56:21
【问题描述】:

我正在使用这样的 GraphQL 枚举类型:

enum PlayerSkill {
  happiness
  game
  run
  water
}

我可以在我的数据库中存储值而不是字符串吗?

在数据库中存储整数而不是字符串更好吗?

【问题讨论】:

    标签: database performance enums graphql graphql-js


    【解决方案1】:

    在 JavaScript 中定义枚举时可以使用 value 属性。 graphql-js documentation 中的示例应该很有帮助。在 Apollo 中,如果您更喜欢 SDL 方法,您可以使用 internal values 实现相同的目的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-04
      相关资源
      最近更新 更多