Skip to content

Commit

Permalink
📝 add getRelation document(api reference)
Browse files Browse the repository at this point in the history
  • Loading branch information
Serpico1899 committed Jan 12, 2024
1 parent fad6958 commit d81ce47
Showing 1 changed file with 78 additions and 3 deletions.
81 changes: 78 additions & 3 deletions pages/src/api/schemas/relationFns/getRelation_Fns.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,80 @@
# getRelation

get inerRelatrion or outerRealtion of one schema
@param name - name of schema
@param relationType - type of relation that we want (inerRelatrion or outrelation)
```ts
getRelation: (name: string, relationType: RelationType)
```

_Get inerRelatrion or outerRealtion of one schema_

<details open>
<summary>
Example
</summary>
<pre>
<code class="language-ts" style="padding: 0;">
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",
},
},
},
},
},
);
<p style="border: 2px solid gray; border-right: transparent; border-left: transparent; padding: 5px 1rem; background-color: #000000" >const getCityRelation = coreApp.schemas.getRelation("city", "relations");</p>
</code>
</pre>
</details>

<details>
<summary>
Return Of Example
</summary>
<pre>
<code class="language-json" style="padding: 0;">
{
"country": {
"schemaName": "country",
"type": "single",
"optional": false,
"relatedRelations": {
"citiesAsc": {
"type": "multiple",
"limit": 5,
"sort": {
"field": "_id",
"order": "asc"
}
}
}
}
}
</code>
</pre>
</details>

<h3>Parameters</h3>
<pre>
<code class="language-ts" style="padding: 0; margin-top: 12px; margin-top: -18px;">
name: string
relationType: <a href="../../types/schema/RelationType.md" target="_blank" style="text-decoration: none; cursor:pointer">RelationType</a>
</code>
</pre>

0 comments on commit d81ce47

Please sign in to comment.