Skip to content

Commit 415f0be

Browse files
committed
Merge branch 'main' of ssh://github.com/dfrnt-labs/terminusdb-docs-static
2 parents 06dbdf5 + 7e45cc2 commit 415f0be

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

schema/all_documents.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,7 +1024,7 @@
10241024
"slug": "add-documents-with-python-client",
10251025
"body": {
10261026
"@type": "Body",
1027-
"value": "After you have imported the `terminusdb_client`, and [created a client](/docs/connect-with-python-client/), [connected to a database](/docs/connect-with-python-client/), and [added a schema](/docs/add-a-schema-with-the-python-client/), you can then use this client to insert a document that conforms to the schema.\n\n## Insert a document\n\nTo insert a document, you should use `insert_document`:\n\n```\ndocument = { '@type' : 'Person', 'name' : \"Jim\" }\nresults = client.insert_document(document)\n```\n\n## Insert multiple documents\n\nTo insert multiple documents you can also invoke `insert_document`:\n\n```\ndocuments = [{ '@type' : 'Person', 'name' : \"Jim\" },\n { '@type' : 'Person', 'name' : \"Jill\" }]\nresults = client.insert_document(document)\n```\n\n## Insert schema document(s)\n\nAdditionally, you can update the schema itself by adding schema documents:\n\n```\nschema = { '@type' : 'Class', '@id' : 'Person', 'name' : 'xsd:string'}\nresults = client.insert_document(schema,graph_type=\"schema\")\n```"
1027+
"value": "After you have imported the `terminusdb_client`, and [created a client](/docs/connect-with-python-client/), [connected to a database](/docs/connect-with-python-client/), and [added a schema](/docs/add-a-schema-with-the-python-client/), you can then use this client to insert a document that conforms to the schema.\n\n## Insert a document\n\nTo insert a document, you should use `insert_document`:\n\n```\ndocument = { '@type' : 'Person', 'name' : \"Jim\" }\nresults = client.insert_document(document)\n```\n\n## Insert multiple documents\n\nTo insert multiple documents you can also invoke `insert_document`:\n\n```\ndocuments = [{ '@type' : 'Person', 'name' : \"Jim\" },\n { '@type' : 'Person', 'name' : \"Jill\" }]\nresults = client.insert_document(documents)\n```\n\n## Insert schema document(s)\n\nAdditionally, you can update the schema itself by adding schema documents:\n\n```\nschema = { '@type' : 'Class', '@id' : 'Person', 'name' : 'xsd:string'}\nresults = client.insert_document(schema,graph_type=\"schema\")\n```"
10281028
},
10291029
"seo_metadata": {
10301030
"@type": "SEOMetadata",
@@ -2495,7 +2495,7 @@
24952495
"slug": "schema-queries-with-woql",
24962496
"body": {
24972497
"@type": "Body",
2498-
"value": "> To use this HowTo, first [clone the Star Wars demo](/docs/clone-a-demo-terminuscms-project/) into your team on TerminusCMS. You will then have access to the data needed for this tutorial.\n\n## Finding elements from the schema.\n\nIn order to query the schema, you can use _graph_ arguments to WOQL. TerminusCMS stores each branch as a pair of graphs, an instance graph and a schema graph.\n\nWe can specify the graph by passing it as an argument to the `quad` word.\n\nTo find all classes in the schema we can write:\n\n```javascript\nlet v = Vars(\"cls\");\nquad(v.cls, \"rdf:type\", \"sys:Class\", \"schema\")\n```\n\nThis results in:\n\ncls\n\n@schema:Film\n\n@schema:People\n\n@schema:Planet\n\n@schema:Species\n\n@schema:Starship\n\n@schema:Vehicle\n\nThe `@schema` denotes the default schema prefix, and makes it clear that this identifier lives in the schema name space rather than the data name space.\n\nWe can also use the typical `triple` word if we use `from` to set our default graph to `schema` instead of `instance`.\n\n```javascript\nlet v = Vars(\"cls\");\nfrom(\"schema\")\n .triple(v.cls, \"rdf:type\", \"sys:Class\")\n```"
2498+
"value": "> To use this HowTo, first [clone the Star Wars demo](/docs/clone-a-demo-terminuscms-project/) into your team on TerminusCMS. You will then have access to the data needed for this tutorial.\n\n## Finding elements from the schema.\n\nIn order to query the schema, you can use _graph_ arguments to WOQL. TerminusCMS stores each branch as a pair of graphs, an instance graph and a schema graph.\n\nWe can specify the graph by passing it as an argument to the `quad` word.\n\nTo find all classes in the schema we can write:\n\n```javascript\nlet v = Vars(\"cls\");\nquad(v.cls, \"rdf:type\", \"sys:Class\", \"schema\")\n```\n\nThis results in:\n\ncls\n\n@schema:Film\n\n@schema:People\n\n@schema:Planet\n\n@schema:Species\n\n@schema:Starship\n\n@schema:Vehicle\n\nThe `@schema` denotes the default schema prefix, and makes it clear that this identifier lives in the schema name space rather than the data name space.\n"
24992499
},
25002500
"seo_metadata": {
25012501
"@type": "SEOMetadata",

src/app/docs/schema-reference-guide/page.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1408,6 +1408,15 @@ The actual definition of person might be given in its home data product as:
14081408
"name" : "xsd:string" }
14091409
```
14101410

1411+
And to use a field with an optional `Person` foreign field, this is how to define the property, just like any other reference, using the `@class`.
1412+
1413+
```json
1414+
"person": {
1415+
"@class": "Person",
1416+
"@type": "Optional"
1417+
}
1418+
```
1419+
14111420
#### Code: An example creating and referring to a foreign type
14121421

14131422
From the command line we can see how an HR data product might interact with an Events data product.
@@ -1693,4 +1702,4 @@ We can then insert a point document which might be written as:
16931702
"type" : "Point",
16941703
"coordinates" : [33.2,24.0]
16951704
}
1696-
```
1705+
```

0 commit comments

Comments
 (0)