Debian Codegraph @

query_write_hooks.go

raw symbols SCIP
1 package rethinkdb
2
3 import (
4 p "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 WriteHookFunc func(id Term, oldVal Term, newVal Term) 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 Term) SetWriteHook(hookFunc WriteHookFunc) Term {
16 var f interface{} = nil
17 if hookFunc != nil {
18 f = funcWrap(hookFunc)
19 }
20 return constructMethodTerm(t, "SetWriteHook", p.Term_SET_WRITE_HOOK, []interface{}{f}, map[string]interface{}{})
21 }
22
23 // WriteHookInfo is a return type of GetWriteHook func.
24 type WriteHookInfo struct {
25 Function []byte `gorethink:"function,omitempty"`
26 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 Term) GetWriteHook() Term {
32 return constructMethodTerm(t, "GetWriteHook", p.Term_GET_WRITE_HOOK, []interface{}{}, map[string]interface{}{})
33 }