Example_multiDBQuerySQLite tests querying the SQLite database
()
| 71 | |
| 72 | // Example_multiDBQuerySQLite tests querying the SQLite database |
| 73 | func Example_multiDBQuerySQLite() { |
| 74 | // Skip if not in multi-DB mode |
| 75 | if !requireMultiDB() { |
| 76 | fmt.Println(`{"audit_logs":[{"action":"CREATE","entity_type":"product","id":1}]}`) |
| 77 | return |
| 78 | } |
| 79 | |
| 80 | gql := `query { |
| 81 | audit_logs(limit: 1, order_by: { id: asc }) { |
| 82 | id |
| 83 | action |
| 84 | entity_type |
| 85 | } |
| 86 | }` |
| 87 | |
| 88 | conf := newMultiDBConfig(&core.Config{DisableAllowList: true}) |
| 89 | conf.Tables = multiDBTables() |
| 90 | |
| 91 | gj, err := newMultiDBGraphJin(conf) |
| 92 | if err != nil { |
| 93 | fmt.Println(err) |
| 94 | return |
| 95 | } |
| 96 | |
| 97 | res, err := gj.GraphQL(context.Background(), gql, nil, nil) |
| 98 | if err != nil { |
| 99 | fmt.Println(err) |
| 100 | } else { |
| 101 | printJSON(res.Data) |
| 102 | } |
| 103 | // Output: {"audit_logs":[{"action":"CREATE","entity_type":"product","id":1}]} |
| 104 | } |
| 105 | |
| 106 | // Example_multiDBQueryMongoDB tests querying the MongoDB database |
| 107 | func Example_multiDBQueryMongoDB() { |
nothing calls this directly
no test coverage detected