Skip to content

Version 0.6.0

Pre-release
Pre-release

Choose a tag to compare

@albrow albrow released this 03 Aug 01:16
· 311 commits to master since this release

This version fixes one or two minor bugs and introduces two new query finishers: ScanOne and FindOne. These methods are useful when you want to find a single model with a query, for example when you want to find a user by their email address.

FindOne returns a pointer to a model instead of a slice of pointers to models. Similarly, ScanOne expects a pointer to a model as an argument instead of a pointer to a slice of pointers to models. In either case, if a model which fits the query criteria is not found, a ModelNotFoundError is returned. The reason an error is returned instead of nil is twofold: (1) go does not allow setting a pointer to nil using reflection. (2) this convention is analogous to the KeyNotFoundError returned by the FindById and ScanById methods. The idea is that if you use these methods you are expecting exactly one model to be returned, and if there is no model, that is a contradiction to your expectations, so an error is raised.

CHANGELOG:

  • Implement and test new FindOne and ScanOne query finishers
  • Fix a bug where running the same query twice with different modifiers could cause errors
  • Remove some old, unused files.