Collection defines methods to work with database tables or collections.
| 23 | |
| 24 | // Collection defines methods to work with database tables or collections. |
| 25 | type Collection interface { |
| 26 | |
| 27 | // Name returns the name of the collection. |
| 28 | Name() string |
| 29 | |
| 30 | // Session returns the Session that was used to create the collection |
| 31 | // reference. |
| 32 | Session() Session |
| 33 | |
| 34 | // Find defines a new result set. |
| 35 | Find(...interface{}) Result |
| 36 | |
| 37 | Count() (uint64, error) |
| 38 | |
| 39 | // Insert inserts a new item into the collection, the type of this item could |
| 40 | // be a map, a struct or pointer to either of them. If the call succeeds and |
| 41 | // if the collection has a primary key, Insert returns the ID of the newly |
| 42 | // added element as an `interface{}`. The underlying type of this ID depends |
| 43 | // on both the database adapter and the column storing the ID. The ID |
| 44 | // returned by Insert() could be passed directly to Find() to retrieve the |
| 45 | // newly added element. |
| 46 | Insert(interface{}) (InsertResult, error) |
| 47 | |
| 48 | // InsertReturning is like Insert() but it takes a pointer to map or struct |
| 49 | // and, if the operation succeeds, updates it with data from the newly |
| 50 | // inserted row. If the database does not support transactions this method |
| 51 | // returns db.ErrUnsupported. |
| 52 | InsertReturning(interface{}) error |
| 53 | |
| 54 | // UpdateReturning takes a pointer to a map or struct and tries to update the |
| 55 | // row the item is refering to. If the element is updated sucessfully, |
| 56 | // UpdateReturning will fetch the row and update the fields of the passed |
| 57 | // item. If the database does not support transactions this method returns |
| 58 | // db.ErrUnsupported |
| 59 | UpdateReturning(interface{}) error |
| 60 | |
| 61 | // Exists returns true if the collection exists, false otherwise. |
| 62 | Exists() (bool, error) |
| 63 | |
| 64 | // Truncate removes all elements on the collection. |
| 65 | Truncate() error |
| 66 | } |
no outgoing calls
no test coverage detected