| 1 | package rethinkdbscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/ |
| 2 | |
| 3 | import ( |
| 4 | pscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/ql2`/ "gopkg.in/rethinkdb/rethinkdb-go.v6/ql2scip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/ql2`/" |
| 5 | ) |
| 6 | |
| 7 | // Rethinkdb proposal: https://github.com/rethinkdb/rethinkdb/issues/5813 |
| 8 | |
| 9 | // WriteHookFunc called by rethinkdb when document is changed. |
| 10 | // id, oldVal or newVal can be null (test with Branch). |
| 11 | type WriteHookFuncscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/WriteHookFunc# func(id Termscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#, oldVal Termscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#, newVal Termscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#) Termscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term# |
| 12 | |
| 13 | // SetWriteHook sets function that will be called each time document in a table is being |
| 14 | // inserted, updated, replaced or deleted. |
| 15 | func (t Termscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#) SetWriteHookscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#SetWriteHook().(hookFunc WriteHookFuncscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/WriteHookFunc#) Termscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term# { |
| 16 | var f interface{} = nil |
| 17 | if hookFunc != nil { |
| 18 | f = funcWrapscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/funcWrap().(hookFunc) |
| 19 | } |
| 20 | return constructMethodTermscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/constructMethodTerm().(t, "SetWriteHook", pscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/ql2`/.Term_SET_WRITE_HOOKscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/ql2`/Term_SET_WRITE_HOOK., []interface{}{f}, map[string]interface{}{}) |
| 21 | } |
| 22 | |
| 23 | // WriteHookInfo is a return type of GetWriteHook func. |
| 24 | type WriteHookInfoscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/WriteHookInfo# struct { |
| 25 | Functionscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/WriteHookInfo#Function. []byte `gorethink:"function,omitempty"` |
| 26 | Queryscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/WriteHookInfo#Query. string `gorethink:"query,omitempty"` |
| 27 | } |
| 28 | |
| 29 | // GetWriteHook reads write hook associated with table. |
| 30 | // Use WriteHookInfo and ReadOne to get results. |
| 31 | func (t Termscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#) GetWriteHookscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#GetWriteHook().() Termscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term# { |
| 32 | return constructMethodTermscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/constructMethodTerm().(t, "GetWriteHook", pscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/ql2`/.Term_GET_WRITE_HOOKscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/ql2`/Term_GET_WRITE_HOOK., []interface{}{}, map[string]interface{}{}) |
| 33 | } |