Through this documentation you'll find a few special concepts, the most important are the ones defined below:
session: a representation of an established connection with a database.
collection: a set of items that belong to a concrete SQL table or a NoSQL collection.
The term 'collection' is used indistinctively by methods that work on both SQL and NoSQL databases.
result set: a subset of items in a collection that match specific
conditions. It is retrieved with
Find(). The whole result set can be
delimited or modified through different methods, like
The figure below ilustrates the session, collection, and result-set concepts:
In order to use
upper/db efficiently, it is advisable that you:
- Understand the database you're working with (relational or document-oriented)
- Use Go structs to describe data models. One struct per collection is a good practice.
- Try to use
db.Collectionmethods applicable to both SQL and NoSQL first.
- Use the SQL builder or raw SQL only when needed.