Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
beerose committed Feb 19, 2025
1 parent 7aa6b1c commit a406dde
Show file tree
Hide file tree
Showing 3 changed files with 161 additions and 189 deletions.
8 changes: 4 additions & 4 deletions docs/intro/quickstart/fastapi/inheritance.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,19 @@ Adding shared properties
@app.get("/decks", response_model=List[Deck])
async def get_decks():
decks = await client.query("""
SELECT Deck {
select Deck {
id,
name,
description,
cards := (
SELECT .cards {
select .cards {
id,
front,
back
}
ORDER BY .order
order by .order
)
}
+ ORDER BY .updated_at DESC
+ order by .updated_at DESC
""")
return decks
3 changes: 3 additions & 0 deletions docs/intro/quickstart/fastapi/modeling.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ Modeling the data
Also of note, the link between ``Card`` and ``Deck`` objects creates a "1-to-n" relationship, where each ``Deck`` object has a link to zero or more ``Card`` objects. When you query the ``Deck.cards`` link, the cards will be unordered, so the ``Card`` type needs an explicit ``order`` property to allow sorting them at query time.
By default, when you try to delete an object that is linked to another object, the database will prevent you from doing so. We want to support removing a ``Card``, so we define a deletion policy on the ``cards`` link that allows deleting the target of this link.
.. code-block:: sdl-diff
:caption: dbschema/default.gel
Expand All @@ -51,6 +53,7 @@ Modeling the data
+ description: str;
+ multi cards: Card {
+ constraint exclusive;
+ on target delete allow;
+ };
+ };
};
Expand Down
Loading

0 comments on commit a406dde

Please sign in to comment.