| 1 | package rethinkdb |
| 2 | |
| 3 | import ( |
| 4 | p "gopkg.in/rethinkdb/rethinkdb-go.v6/ql2" |
| 5 | ) |
| 6 | |
| 7 | // Row returns the currently visited document. Note that Row does not work within |
| 8 | // subqueries to access nested documents; you should use anonymous functions to |
| 9 | // access those documents instead. Also note that unlike in other drivers to |
| 10 | // access a rows fields you should call Field. For example: |
| 11 | // r.row("fieldname") should instead be r.Row.Field("fieldname") |
| 12 | var Row = constructRootTerm("Doc", p.Term_IMPLICIT_VAR, []interface{}{}, map[string]interface{}{}) |
| 13 | |
| 14 | // Literal replaces an object in a field instead of merging it with an existing |
| 15 | // object in a merge or update operation. |
| 16 | func Literal(args ...interface{}) Term { |
| 17 | return constructRootTerm("Literal", p.Term_LITERAL, args, map[string]interface{}{}) |
| 18 | } |
| 19 | |
| 20 | // Field gets a single field from an object. If called on a sequence, gets that field |
| 21 | // from every object in the sequence, skipping objects that lack it. |
| 22 | func (t Term) Field(args ...interface{}) Term { |
| 23 | return constructMethodTerm(t, "Field", p.Term_GET_FIELD, args, map[string]interface{}{}) |
| 24 | } |
| 25 | |
| 26 | // HasFields tests if an object has all of the specified fields. An object has a field if |
| 27 | // it has the specified key and that key maps to a non-null value. For instance, |
| 28 | // the object `{'a':1,'b':2,'c':null}` has the fields `a` and `b`. |
| 29 | func (t Term) HasFields(args ...interface{}) Term { |
| 30 | return constructMethodTerm(t, "HasFields", p.Term_HAS_FIELDS, args, map[string]interface{}{}) |
| 31 | } |
| 32 | |
| 33 | // Pluck plucks out one or more attributes from either an object or a sequence of |
| 34 | // objects (projection). |
| 35 | func (t Term) Pluck(args ...interface{}) Term { |
| 36 | return constructMethodTerm(t, "Pluck", p.Term_PLUCK, args, map[string]interface{}{}) |
| 37 | } |
| 38 | |
| 39 | // Without is the opposite of pluck; takes an object or a sequence of objects, and returns |
| 40 | // them with the specified paths removed. |
| 41 | func (t Term) Without(args ...interface{}) Term { |
| 42 | return constructMethodTerm(t, "Without", p.Term_WITHOUT, args, map[string]interface{}{}) |
| 43 | } |
| 44 | |
| 45 | // Merge merges two objects together to construct a new object with properties from both. |
| 46 | // Gives preference to attributes from other when there is a conflict. |
| 47 | func (t Term) Merge(args ...interface{}) Term { |
| 48 | return constructMethodTerm(t, "Merge", p.Term_MERGE, funcWrapArgs(args), map[string]interface{}{}) |
| 49 | } |
| 50 | |
| 51 | // Append appends a value to an array. |
| 52 | func (t Term) Append(args ...interface{}) Term { |
| 53 | return constructMethodTerm(t, "Append", p.Term_APPEND, args, map[string]interface{}{}) |
| 54 | } |
| 55 | |
| 56 | // Prepend prepends a value to an array. |
| 57 | func (t Term) Prepend(args ...interface{}) Term { |
| 58 | return constructMethodTerm(t, "Prepend", p.Term_PREPEND, args, map[string]interface{}{}) |
| 59 | } |
| 60 | |
| 61 | // Difference removes the elements of one array from another array. |
| 62 | func (t Term) Difference(args ...interface{}) Term { |
| 63 | return constructMethodTerm(t, "Difference", p.Term_DIFFERENCE, args, map[string]interface{}{}) |
| 64 | } |
| 65 | |
| 66 | // SetInsert adds a value to an array and return it as a set (an array with distinct values). |
| 67 | func (t Term) SetInsert(args ...interface{}) Term { |
| 68 | return constructMethodTerm(t, "SetInsert", p.Term_SET_INSERT, args, map[string]interface{}{}) |
| 69 | } |
| 70 | |
| 71 | // SetUnion adds several values to an array and return it as a set (an array with |
| 72 | // distinct values). |
| 73 | func (t Term) SetUnion(args ...interface{}) Term { |
| 74 | return constructMethodTerm(t, "SetUnion", p.Term_SET_UNION, args, map[string]interface{}{}) |
| 75 | } |
| 76 | |
| 77 | // SetIntersection calculates the intersection of two arrays returning values that |
| 78 | // occur in both of them as a set (an array with distinct values). |
| 79 | func (t Term) SetIntersection(args ...interface{}) Term { |
| 80 | return constructMethodTerm(t, "SetIntersection", p.Term_SET_INTERSECTION, args, map[string]interface{}{}) |
| 81 | } |
| 82 | |
| 83 | // SetDifference removes the elements of one array from another and return them as a set (an |
| 84 | // array with distinct values). |
| 85 | func (t Term) SetDifference(args ...interface{}) Term { |
| 86 | return constructMethodTerm(t, "SetDifference", p.Term_SET_DIFFERENCE, args, map[string]interface{}{}) |
| 87 | } |
| 88 | |
| 89 | // InsertAt inserts a value in to an array at a given index. Returns the modified array. |
| 90 | func (t Term) InsertAt(args ...interface{}) Term { |
| 91 | return constructMethodTerm(t, "InsertAt", p.Term_INSERT_AT, args, map[string]interface{}{}) |
| 92 | } |
| 93 | |
| 94 | // SpliceAt inserts several values in to an array at a given index. Returns the modified array. |
| 95 | func (t Term) SpliceAt(args ...interface{}) Term { |
| 96 | return constructMethodTerm(t, "SpliceAt", p.Term_SPLICE_AT, args, map[string]interface{}{}) |
| 97 | } |
| 98 | |
| 99 | // DeleteAt removes an element from an array at a given index. Returns the modified array. |
| 100 | func (t Term) DeleteAt(args ...interface{}) Term { |
| 101 | return constructMethodTerm(t, "DeleteAt", p.Term_DELETE_AT, args, map[string]interface{}{}) |
| 102 | } |
| 103 | |
| 104 | // ChangeAt changes a value in an array at a given index. Returns the modified array. |
| 105 | func (t Term) ChangeAt(args ...interface{}) Term { |
| 106 | return constructMethodTerm(t, "ChangeAt", p.Term_CHANGE_AT, args, map[string]interface{}{}) |
| 107 | } |
| 108 | |
| 109 | // Keys returns an array containing all of the object's keys. |
| 110 | func (t Term) Keys(args ...interface{}) Term { |
| 111 | return constructMethodTerm(t, "Keys", p.Term_KEYS, args, map[string]interface{}{}) |
| 112 | } |
| 113 | |
| 114 | func (t Term) Values(args ...interface{}) Term { |
| 115 | return constructMethodTerm(t, "Values", p.Term_VALUES, args, map[string]interface{}{}) |
| 116 | } |
| 117 | |
| 118 | // Object creates an object from a list of key-value pairs, where the keys must be strings. |
| 119 | func Object(args ...interface{}) Term { |
| 120 | return constructRootTerm("Object", p.Term_OBJECT, args, map[string]interface{}{}) |
| 121 | } |