Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ match
$book isa paperback, has isbn-13 "9780446310789";
$line isa order-line (order: $order, item: $book);
fetch {
"id": $order.id;
"quantity": $line.quantity;
"id": $order.id,
"quantity": $line.quantity
};
----

Expand Down Expand Up @@ -352,7 +352,7 @@ $book isa paperback, has isbn-13 "9780446310789";
$line isa order-line (order: $order, item: $book);
delivery (deliverer: $courier, delivered: $order, destination: $address);
fetch {
"id": $order.id;
"id": $order.id,
"quantity": $line.quantity,
"name": $courier.name,
"street": $address.street
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ Write a query to retrieve _all_ ISBNs of _all_ books in the database.
match
$book isa book;
fetch {
"isbn": $book.isbn
"isbn": [ $book.isbn ]
};
----

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,10 @@ So far, the Insert queries we've seen have only created entirely new entities, r
[,typeql]
----
match
$book isa book, has isbn-13 "9780486282114";
$stock isa stock;
$frankenstein isa book, has $stock, has isbn "9780486282114";
insert
$book has stock 20;
$frankenstein has stock 20;
Comment on lines 148 to +152
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As is pointed out later in Data validation, the ebook entity does not own stock. Running this example as-is raises an error for this reason. So, I offer up this workaround; it's a little ugly but it runs.

Whether this behaviour is intended or whether it is an issue with the type inference engine is beyond me!

----
__-> Commit__

Expand Down Expand Up @@ -210,10 +211,12 @@ put $book isa book, has isbn "0195153448";
----

A put is equivalent to doing:

[,typeql]
----
match not { <pattern> };
insert <pattern>;
----
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This missing delimiter is causing quite a considerable rendering problem on the site.


**It's highly recommended use `put` with a `key`-ed attributes**. This will prevent duplicates from emerging during concurrent transactions, as one will be forced to fail.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ In addition to being more efficient and easier for readers to interpret, these q
----
match
$book isa book, has $art;
$art "art" isa genre;
$art isa genre "art";
delete
has $art of $book;
insert
Expand All @@ -59,7 +59,7 @@ When updating an attribute ownership (or indeed, a role player in an existing re
----
match
$book isa paperback, has isbn-10 "0060929790";
update $book has stock 20;
update $book has stock 25;
----

The `update` clause will, for each statement written, set the new attribute to be the only attribute owned by the owner. In this example, for the specific paperback book, it sets the stock to 25, replacing any existing stock value.
Comment on lines +62 to 65
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dealer's choice whether to change the block or the descriptor, but they should match.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ insert
locating ($us, $ga);
----

In this case, the query was invalid because TypeDB cannot infer the roles that `$us` and `$ga` should play, but there are many reasons a query can be invalid. Try running each of the following ones to see what happens.
In this case, the query was invalid because TypeDB cannot infer the roles that `$us` and `$ga` should play, but there are many reasons a query can be invalid. Try running (and committing) each of the following ones to see what happens.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The second query runs and only raises an error when you try to commit it.


[,typeql]
----
Expand Down