How I create relations between entities on JayData?
This is my table schema:
$data.Entity.extend("OrdemServico", {
Status: { type: String },
SafAnoSafra: { type: "int" },
LancObservacao: { type: String },
LancDtPrevIni: { type: Date },
LancDtPrevFim: { type: Date },
LancData: { type: Date },
CodSubprocesso: { type: "int" },
CodProcesso: { type: "int" },
CodOs: { type: "int" },
CodFuncEmpr: { type: "int" },
CodFuncAplic: { type: "int" },
CodFuncApliEmpr: { type: "int" },
CodFunc: { type: "int" },
CodFrente: { type: "int" },
CodEmpr: { type: "int" }
});
$data.Entity.extend("Local", {
SafAnoSafra: { type: "int" },
PerAreaOs: { type: "decimal" },
IdDivi4: { type: "int" },
CodOs: { type: "int" },
CodEmpr: { type: "int" },
CodDivi4: { type: "int" },
CodDivi3: { type: "int" },
CodDivi2: { type: "int" },
CodDivi1: { type: "int" },
AreaOs: { type: "decimal" },
AreaLiquida: { type: "decimal" }
});
The relation is:
OrdemServico.SafAnoSafra -> Local.SafAnoSafra
OrdemServico.CodEmpr -> Local.CodEmpr
OrdemServico.CodOs -> Local.CodOs
After a lot of searches I have found something near this on the official JayData tutorials, but it still not so clear about it(at least to me) on this link. According to it, what I have to do to stablish a relation is something like this:
Locais: {type: "Array", elementType: "$org.types.Local", navigationProperty: "OrdemServico"}
for OrdemServico entity...
OrdemServico: { type: "Array", elementType: "$org.types.OrdemServico", navigationProperty: "Local"}
for Local entity.
That breaks my code and doesn't works. Don't know how to go any further.