Skip to content

Commit 6a147d0

Browse files
committed
feat: unique table per example
1 parent 4fb2fd7 commit 6a147d0

23 files changed

+277
-616
lines changed

examples/go/xorm/README.md

+15-15
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ Example for a text field:
6767
```go
6868
func (et EncryptedTextField) ToDB() ([]byte, error) {
6969
etCs := goeql.EncryptedText(et)
70-
// e.g table name is "examples" and field is "encrypted_text_field"
71-
return (&etCs).Serialize("examples", "encrypted_text_field")
70+
// e.g table name is "goexamples" and field is "encrypted_text_field"
71+
return (&etCs).Serialize("goexamples", "encrypted_text_field")
7272
}
7373
7474
func (et *EncryptedTextField) FromDB(data []byte) error {
@@ -90,8 +90,8 @@ Example for a jsonb field:
9090
```go
9191
func (ej EncryptedJsonbField) ToDB() ([]byte, error) {
9292
ejCs := goeql.EncryptedJsonb(ej)
93-
// e.g table name is "examples" and field is "encrypted_jsonb_field"
94-
return (&ejCs).Serialize("examples", "encrypted_jsonb_field")
93+
// e.g table name is "goexamples" and field is "encrypted_jsonb_field"
94+
return (&ejCs).Serialize("goexamples", "encrypted_jsonb_field")
9595
}
9696
9797
func (ej *EncryptedJsonbField) FromDB(data []byte) error {
@@ -115,10 +115,10 @@ These checks will validate that the json payload is correct and that encrypted d
115115
Example:
116116
117117
```sql
118-
ALTER TABLE examples ADD CONSTRAINT encrypted_text_field_encrypted_check
118+
ALTER TABLE goexamples ADD CONSTRAINT encrypted_text_field_encrypted_check
119119
CHECK ( cs_check_encrypted_v1(encrypted_text_field) );
120120
121-
ALTER TABLE examples ADD CONSTRAINT encrypted_jsonb_encrypted_check
121+
ALTER TABLE goexamples ADD CONSTRAINT encrypted_jsonb_encrypted_check
122122
CHECK ( cs_check_encrypted_v1(encrypted_jsonb_field) );
123123
```
124124
@@ -127,17 +127,17 @@ Example:
127127
Example:
128128
129129
```sql
130-
SELECT cs_add_index_v1('examples', 'encrypted_text_field', 'unique', 'text', '{"token_filters": [{"kind": "downcase"}]}');
131-
SELECT cs_add_index_v1('examples', 'encrypted_text_field', 'match', 'text');
132-
SELECT cs_add_index_v1('examples', 'encrypted_text_field', 'ore', 'text');
133-
SELECT cs_add_index_v1('examples', 'encrypted_jsonb_field', 'ste_vec', 'jsonb', '{"prefix": "examples/encrypted_jsonb_field"}');
130+
SELECT cs_add_index_v1('goexamples', 'encrypted_text_field', 'unique', 'text', '{"token_filters": [{"kind": "downcase"}]}');
131+
SELECT cs_add_index_v1('goexamples', 'encrypted_text_field', 'match', 'text');
132+
SELECT cs_add_index_v1('goexamples', 'encrypted_text_field', 'ore', 'text');
133+
SELECT cs_add_index_v1('goexamples', 'encrypted_jsonb_field', 'ste_vec', 'jsonb', '{"prefix": "goexamples/encrypted_jsonb_field"}');
134134
135135
-- The below indexes will also need to be added to enable full search functionality on the encrypted columns
136136
137-
CREATE UNIQUE INDEX ON examples(cs_unique_v1(encrypted_text_field));
138-
CREATE INDEX ON examples USING GIN (cs_match_v1(encrypted_text_field));
139-
CREATE INDEX ON examples (cs_ore_64_8_v1(encrypted_text_field));
140-
CREATE INDEX ON examples USING GIN (cs_ste_vec_v1(encrypted_jsonb_field));
137+
CREATE UNIQUE INDEX ON goexamples(cs_unique_v1(encrypted_text_field));
138+
CREATE INDEX ON goexamples USING GIN (cs_match_v1(encrypted_text_field));
139+
CREATE INDEX ON goexamples (cs_ore_64_8_v1(encrypted_text_field));
140+
CREATE INDEX ON goexamples USING GIN (cs_ste_vec_v1(encrypted_jsonb_field));
141141
142142
-- Run these functions to activate
143143
@@ -174,7 +174,7 @@ Examples of how to use these are in the [e2e_test.go](./e2e_test.go) file.
174174
Below is an example of running a match query on a text field.
175175
176176
```go
177-
query, errTwo := goeql.MatchQuery("some", "examples", "encrypted_text_field")
177+
query, errTwo := goeql.MatchQuery("some", "goexamples", "encrypted_text_field")
178178
if errTwo != nil {
179179
log.Fatalf("Error marshaling encrypted_text_field: %v", errTwo)
180180
}

0 commit comments

Comments
 (0)