getRelation
getRelation: (name: string, relationType: RelationType)
Get inerRelatrion or outerRealtion of one schema
Example
const coreApp = lesan();
const locationPure = {
name: string(),
population: number(),
abb: string(),
};
const cities = coreApp.odm.newModel(
"city",
locationPure,
{
country: {
schemaName: "country",
type: "single",
optional: false,
relatedRelations: {
cities: {
type: "multiple",
limit: 5,
sort: {
field: "_id",
order: "asc",
},
},
},
},
},
);
const getCityRelation = coreApp.schemas.getRelation("city", "relations");
Return Of Example
{
"country": {
"schemaName": "country",
"type": "single",
"optional": false,
"relatedRelations": {
"citiesAsc": {
"type": "multiple",
"limit": 5,
"sort": {
"field": "_id",
"order": "asc"
}
}
}
}
}
Parameters
name: string
relationType: RelationType