kingbase数据库

lrf cd069367de update il y a 12 heures
importData 8962dcd03a update il y a 1 semaine
src cd069367de update il y a 12 heures
test 9de8eb16b5 init il y a 3 mois
.editorconfig 9de8eb16b5 init il y a 3 mois
.eslintrc.json 9de8eb16b5 init il y a 3 mois
.gitignore 9de8eb16b5 init il y a 3 mois
.prettierrc.js 9de8eb16b5 init il y a 3 mois
README.md f95030e593 消息发送 il y a 1 mois
README.zh-CN.md 9de8eb16b5 init il y a 3 mois
bootstrap.js 9de8eb16b5 init il y a 3 mois
ecosystem.config.js c0c3e5c9e2 添加pm2文件和本机启动配置文件,本机启动指令 il y a 3 mois
jest.config.js 9de8eb16b5 init il y a 3 mois
package-lock.json d7da73e82f 邮件找回密码 il y a 5 jours
package.json d7da73e82f 邮件找回密码 il y a 5 jours
tsconfig.json 0913556669 update il y a 1 mois

README.md

sql项目转换后的注意事项

1.数据库数据类型

1.1 字符串,有长度的使用 character varying; 不加限制的使用 text

1.2 数字使用 integer; 金额使用 money

1.3 时间使用 timestamp without time zone

开始时间与结束时间都分为2个字段 表属性在Column装饰器上添加:

  transformer: { from: value => dayjs(value).format('YYYY-MM-DD HH:mm:ss'), to: value => value } 

用来格式化输出格式

1.4 不能像mongodb一样轻易使用JSON文档模式

  • 因为JSONB数据中,只有精确查询: Array<any>:[1,2,3] JSONB_CONTAINS/JSONB_EXISTS(column, :column)', { column: 1 } object: {test:'123'} JSONB_CONTAINS(column, :val)', { val: { test: '123' } } Array<object> where "${root_column}" @> '[{"${key}": ${value} }]' 导致文档模式查询会变得不可能,所以使用JSONB数据格式的情况,只有准确查询; 将文档模式的设计变成表关联,联查出来

2.数据库导入

2.1 带id导入数据

带id导入数据后,需要执行数据库命令,使id的序列从导入数据的最后一条数据开始,否则会出现id已存在问题:

  SELECT setval('"company_id_seq"', (SELECT max(id) FROM "company"));
  SELECT setval('"表名_唯一约束的字段_seq"', (SELECT max(唯一约束的字段) FROM 表名));