Skip to content

Commit 47e397a

Browse files
committed
corrected association implementation
1 parent 47cc8b4 commit 47e397a

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

api_graphql.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ And we will describe the associations between the models `Record` and `Item`.
278278
"associations":{
279279
"record":{
280280
"type": "many_to_one",
281-
"implementation": "foreignkey",
281+
"implementation": "foreignkeys",
282282
"reverseAssociation": "items",
283283
"target": "Record",
284284
"targetKey": "recordId",
@@ -296,7 +296,7 @@ And we will describe the associations between the models `Record` and `Item`.
296296
"associations":{
297297
"items": {
298298
"type": "one_to_many",
299-
"implementation": "foreignkey",
299+
"implementation": "foreignkeys",
300300
"reverseAssociation": "record",
301301
"target": "Item",
302302
"targetKey": "recordId",

cassandra_storageType.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Cassandra, due to its distributed nature does _not_ implement traditional limit-
5555
Cassandra _only_ supports the sorting of the results from a query by specifically defining this via the [compound primary key](https://docs.datastax.com/en/cql-oss/3.3/cql/cql_using/useCompoundPrimaryKeyConcept.html) and the definition of a column by which to partition the data. Since zendro, for now, doen't implement those kind of primary keys, _no_ sorting of cassandra results is possible. The default is defined by cassandras internal [`token`](https://docs.datastax.com/en/cql-oss/3.3/cql/cql_using/useToken.html) function.
5656

5757
### Associations
58-
Associations with the `targetStoragetType` set to Cassandra have some restrictions on searching. Since the association is resolved via adding a search for either `eq` to the respective foreignkey or `in` the foreignkey array in case the association is of type `many_to_many`. Cassandra does not allow multiple Equal restrictions on the id field, the driver will throw an Error. To circumvent that a workaround where searches on the idField are merged with the search on the foreignkey(s) is implemented.
58+
Associations with the `targetStorageType` set to Cassandra have some restrictions on searching. Since the association is resolved via adding a search for either `eq` to the respective foreignkey or `in` the foreignkey array in case the association is of type `many_to_many`. Cassandra does not allow multiple Equal restrictions on the id field, the driver will throw an Error. To circumvent that a workaround where searches on the idField are merged with the search on the foreignkey(s) is implemented.
5959

6060
Be aware that the workaround only works because cassandra does _not_ support the OR operator. There are also the following pitfalls to consider:
6161
- cassandra does not allow SELECT queries on indexed columns with IN clause for the PRIMARY KEY.

setup_data_scheme.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ name | Type | Description
7575
------- | ------- | --------------
7676
*type* | String | Type of association, either `one_to_one`, `one_to_many`, `many_to_one`, or `many_to_many`.
7777
*target* | String | Name of model to which the current model will be associated with.
78-
*implementation* | String | implementation type of the association. Can be one of `foreignkey`, `generic` or `sql_cross_table` (only for `many_to_many`)
78+
*implementation* | String | implementation type of the association. Can be one of `foreignkeys`, `generic` or `sql_cross_table` (only for `many_to_many`)
7979
*reverseAssociation* | String | The name of the reverse association from the other model. This field is only mandatory for building the [single-page-app](https://github.com/Zendro-dev/single-page-app), *not* for generating the the graphql-server code via this repository.
8080
*targetStorageType* | String | Type of storage where the target model is stored.
8181
*useDataLoader* | Boolean | If it is set to `true`, server could fetch multiple records within one query for `readOne<model>` API.
@@ -108,7 +108,7 @@ Examples:
108108
"associations":{
109109
"publisher" : {
110110
"type" : "many_to_one", // association type
111-
"implementation": "foreignkey",
111+
"implementation": "foreignkeys",
112112
"reverseAssociation": "books",
113113
"target" : "publisher", // the target model name is `publisher`
114114
"targetKey" : "publisher_id", // foreign key for this association
@@ -130,7 +130,7 @@ Examples:
130130
"associations":{
131131
"books" : {
132132
"type" : "one_to_many", // association type
133-
"implementation": "foreignkey",
133+
"implementation": "foreignkeys",
134134
"reverseAssociation": "publisher",
135135
"target" : "book", // the target model name is `book`
136136
"targetKey" : "publisher_id", // foreign key for this association
@@ -144,7 +144,7 @@ Examples:
144144
Storing the association via paired-end foreign keys means that both associated data-models contain a reference (foreign key) to the associated records. Storing the keys in that way guarantees read and search efficiency, especially in a distributed context, at the cost of time and storage-space when handling write actions. Since the keys are stored at both ends the information needs to be updated at both ends as well, which is slower and more prone to errors.
145145

146146
Many-to-many associations can be stored via paired-end associations. In this case both models will hold an array attribute which will store ids from the associated records. These two attributes will be described in the association as `sourceKey` and `targetKey`.
147-
Also, for indicating that the association is a many-to-many association via arrays as foreign key, we need to specify in the association info the `implementation` field as `foreignkey`.
147+
Also, for indicating that the association is a many-to-many association via arrays as foreign key, we need to specify in the association info the `implementation` field as `foreignkeys`.
148148

149149
To define paired-end foreign key associations the following arguments need to be added:
150150

@@ -174,7 +174,7 @@ Assume we have an many_to_many association between two models `book` and `author
174174
"associations":{
175175
"books":{
176176
"type": "many_to_many", // association type
177-
"implementation": "foreignkey",
177+
"implementation": "foreignkeys",
178178
"reverseAssociation": "authors",
179179
"target": "book", // target model name
180180
"targetKey": "author_ids", // foreign key array stored in target model
@@ -184,7 +184,7 @@ Assume we have an many_to_many association between two models `book` and `author
184184
},
185185
"cards":{
186186
"type": "one_to_many", // association type
187-
"implementation": "foreignkey",
187+
"implementation": "foreignkeys",
188188
"reverseAssociation": "author",
189189
"target": "card", // target model name
190190
"targetKey": "author_id", // foreign key stored in target model
@@ -214,7 +214,7 @@ Assume we have an many_to_many association between two models `book` and `author
214214
"associations":{
215215
"authors":{
216216
"type": "many_to_many", // association type
217-
"implementation": "foreignkey",
217+
"implementation": "foreignkeys",
218218
"reverseAssociation": "books",
219219
"target": "author", // target model name
220220
"targetKey": "book_ids", // foreign key array stored in target model
@@ -241,7 +241,7 @@ Assume we have an many_to_many association between two models `book` and `author
241241
"associations":{
242242
"author":{
243243
"type": "many_to_one", // association type
244-
"implementation": "foreignkey",
244+
"implementation": "foreignkeys",
245245
"reverseAssociation": "cards",
246246
"target": "author", // target model name
247247
"targetKey": "card_ids", // foreign key array stored in target model

what_are_data_models.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ To translate the conceptual diagram into JSON, we need follow the [JSON specific
5454
"associations": {
5555
"specimen_information": { // give your association an informative name
5656
"type" : "one_to_one",
57-
"implementation": "foreignkey",
57+
"implementation": "foreignkeys",
5858
"reverseAssociation": "taxon_information", // The name of the reverse association defined in the specimen model
5959
"target": "specimen",
6060
"targetKey": "specimen_id",
@@ -84,7 +84,7 @@ To translate the conceptual diagram into JSON, we need follow the [JSON specific
8484
"associations": {
8585
"medicinal_plants": {
8686
"type" : "one_to_many",
87-
"implementation": "foreignkey",
87+
"implementation": "foreignkeys",
8888
"reverseAssociation": "collection",
8989
"target": "specimen",
9090
"targetKey": "specimen_id",

0 commit comments

Comments
 (0)