1
I’m needing to do a many-to-many table on Indexeddb, where I have People Classes and People Classes, one can participate in several classes, and several classes can have several students, so I created this class table person, where I put people code, class code, a flag to identify who’s in that class. Follow the code of my table.
var pessoa turma = db.createObjectStore("tbl_PESSOA_TURMA", {keyPath: "COD_IDENT_TURMA"});
pessoa_turma .createIndex("COD_IDENT_PESSO", "COD_IDENT_PESSO", {unique: false});
pessoa_turma .createIndex("COD_IDENT_CELUL", "COD_IDENT_TURMA", {unique: false});
pessoa_turma .createIndex("FLG_IDENT_PESSO", "FLG_IDENT_PESSO", {unique: false});
pessoa_turma .createIndex("COD_IDULT_ATUAL", "COD_IDULT_ATUAL", {unique: false});
pessoa_turma .createIndex("DAT_ULTIM_ATUAL", "DAT_ULTIM_ATUAL", {unique: false});
With this code I am only able to save some part of the class, because the class code is suffering a "group by", for example I have 16 people, and it appears only 3 classes, because these 16 people are in 3 different classes.
How do I accept the registration of more than one code ? I need the class code to look like a primary key, because in class research I need it to return to me all the codes of people who have class 'X code'.
If this table is
turma_pessoas
, PK can’t just be the class code. You said yourself that this table is from an N-M relationship, that is, the PK should be COD_IDENT_TURMA and COD_IDENT_PESSO.– emanuelsn
However Indexeddb does not allow this.
– Renan Rodrigues