node.js - 如何在 Sequelize 中使用 Postgres 的 BIGSERIAL?
问题描述
我想在 Sequelize 模型中使用 PostgreSQL BIG SERIAL 类型作为 id。我该怎么做呢?我发现 Sequelize 在执行此操作时使用 SERIAL:
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true // this converts INT to SERIAL for Postgres
},
但是如何使它成为 BIGSERIAL 呢?
解决方案
我想你的答案可以在这个 Github issue上找到。
本质上,只需设置:
type: Sequelize.BIGINT,
primaryKey: true,
autoIncrement: true
数据类型 serial 和 bigserial 不是真正的类型,而只是用于创建唯一标识符列的符号方便(类似于某些其他数据库支持的 AUTO_INCREMENT 属性)。
推荐阅读
- html - 点击图像以获取输入文件功能
- excel - 以 Excel 的货币格式添加自定义符号
- java - 无法连接到远程 SSH 服务器上的 HBase 容器
- python - 是否有像 ONNX 这样的格式来持久化数据预处理/特征工程管道而不进行序列化?
- react-native - 如何使用 react-native-navigation 在屏幕之间正确导航?
- asp.net-core - 如何将对象反序列化为单项列表?
- javascript - 新上传javascript时自动更新图片
- azure - 配置了 Azure 文件共享的 Pod。我还需要 PersistentVolume 和 PVC 吗?
- kubernetes - Kubernetes 验证 webhook 的自签名证书可以吗?
- linux - 在一行上打印变量的值(没有新行)