Sequelize-处理<key,value>关联

时间:2018-07-11 12:41:01

标签: node.js sequelize.js

我目前正在使用Sequelize作为ORM,将具有Postgresql数据库的现有JEE应用程序迁移到NodeJS应用程序。

在我的Java代码中,我有一些无法迁移的模型,它们是基于关系的模型,例如:

public class CalculProgramme {    
        public Long id;    
        public Double value;  
}

public class Programme {    
        public Long id;    
        public Map<String, CalculProgramme> calculs;
}

我的数据库架构是:

CREATE TABLE programme
(
  id bigint NOT NULL,
  CONSTRAINT programme_pkey PRIMARY KEY (id)
);

CREATE TABLE calcul_programme (
  id bigint NOT NULL,
  value double precision,
  CONSTRAINT calcul_programme_pkey PRIMARY KEY (id)
);

CREATE TABLE programme_calcul_programme (
  programme_id bigint NOT NULL,
  calculs_id bigint NOT NULL,
  calculs_key character varying(255) NOT NULL,
  CONSTRAINT programme_calcul_programme_pkey PRIMARY KEY (programme_id, calculs_id),
  CONSTRAINT fk_programme_calcul_programme_programme FOREIGN KEY (programme_id) REFERENCES programme (id),
  CONSTRAINT fk_programme_calcul_programme_calculs FOREIGN KEY (calculs_id) REFERENCES calcul_programme (id)
);

我的问题是:我可以使用Sequelize保留该架构吗?如果是,则使用哪个序列关联以及如何配置它?

0 个答案:

没有答案