-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
API: First, join object need to be created, which specifies collections and join condition: ``` join := tigris.GetJoin[LeftCollModel, RightCollModel](db, "{left field}", "{right field}", [options]) ``` This creates a join between LeftCollModel and RightCollModel on equality of `{left field}` to `{right field}`. Created object then can be used to issue one or multiple read requests: ``` it, err := join.Read(ctx, filter.Eq("Field1", 1)) ``` filter condition of read API is applied to the left table. Iterator then returns of the rows matching the condition along with the corresponding rows from the right table, which satisfies the join condition. var l LeftCollModel var r []*RightCollModel for it.Next(&l, &r) { fmt.Printf("l=%v r=%v\n", l, r) } By default the documents which doesn't have matching documents in the right table returned in the results. These results can be skipped by providing `&JoinOptions{Type: tigris.InnerJoin}` option to GetJoin API. It is not required for the left field values or right field values to be unique. The value of the array fields are matched as is by default, by using `&JoinOptions{ArrayUnroll: true}` option individual array items can be matched in the right table. Implementation details: First request is issued to the left table with filter provided to Read API. Result is read into memory and request is prepared for the right table. Which will have the following filter `filter.Or(filter.Eq("{right field}", {left field value fetched by left query}), ...)`. Result from the first query is put in the map with {left field} value as the key, while reading the result from second query we append it to the corresponding map bucket. So as merge is done in the memory joins should be used for relatively small result sets only.
- Loading branch information
Showing
15 changed files
with
1,341 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.