MCPcopy
hub / github.com/upper/db / Collection

Interface Collection

collection.go:25–66  ·  view source on GitHub ↗

Collection defines methods to work with database tables or collections.

Source from the content-addressed store, hash-verified

23
24// Collection defines methods to work with database tables or collections.
25type 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}

Callers 8

CountMethod · 0.95
TestGroupMethod · 0.95
compileQueryMethod · 0.95
FindMethod · 0.95
andMethod · 0.80
whereMethod · 0.80
TestGroupMethod · 0.95
TestGroupMethod · 0.95

Implementers 1

collectionWithSessioninternal/sqladapter/collection.go

Calls

no outgoing calls

Tested by

no test coverage detected