Documentation ¶
Index ¶
- Variables
- func Count(ctx context.Context, collectionName string, query bson.M) (int, error)
- func CountUnscoped(ctx context.Context, collectionName string, query bson.M) (int, error)
- func Create(ctx context.Context, collectionName string, doc document) error
- func Destroy(ctx context.Context, collectionName string, doc destroyable) error
- func EnsureParanoidIndices(ctx context.Context, collectionNames ...string)
- func Find(ctx context.Context, collectionName string, id bson.ObjectId, doc scopable, ...) error
- func FindOne(ctx context.Context, collectionName string, query bson.M, doc scopable, ...) error
- func FindOneUnscoped(ctx context.Context, collectionName string, query bson.M, doc interface{}) error
- func FindUnscoped(ctx context.Context, collectionName string, id bson.ObjectId, doc interface{}, ...) error
- func ReallyDestroy(ctx context.Context, collectionName string, doc document) error
- func Restore(ctx context.Context, collectionName string, doc document) error
- func Save(ctx context.Context, collectionName string, doc document) error
- func Update(ctx context.Context, collectionName string, update bson.M, doc document) error
- func Where(ctx context.Context, collectionName string, query bson.M, data interface{}, ...) error
- func WhereIter(ctx context.Context, collectionName string, query bson.M, ...) error
- func WhereIterUnscoped(ctx context.Context, collectionName string, query bson.M, ...) error
- func WhereUnscoped(ctx context.Context, collectionName string, query bson.M, data interface{}, ...) error
- type Base
- type Closer
- type Paranoid
- type SortField
- type Validable
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrValidateNoInternalErrorFunc = stderrors.New("no validation returning an internal error has been implemented")
Functions ¶
func CountUnscoped ¶ added in v1.3.0
func Create ¶
Create inserts the document in the database, returns an error if document already exists and set CreatedAt timestamp
func EnsureParanoidIndices ¶
func Find ¶
func Find(ctx context.Context, collectionName string, id bson.ObjectId, doc scopable, sortFields ...SortField) error
Find is finding the model with objectid id in the collection name, with its default scope for paranoid documents, it won't look at documents tagged as deleted
func FindOneUnscoped ¶
func FindUnscoped ¶
func FindUnscoped(ctx context.Context, collectionName string, id bson.ObjectId, doc interface{}, sortFields ...SortField) error
FindUnscoped is similar as Find but does not care of the default scope of the document.
func ReallyDestroy ¶
func WhereIterUnscoped ¶
Types ¶
type Base ¶
type Base struct { ID bson.ObjectId `bson:"_id" json:"id"` CreatedAt time.Time `bson:"created_at" json:"created_at"` UpdatedAt time.Time `bson:"updated_at" json:"updated_at"` }
func (Base) IsPersisted ¶
type Paranoid ¶
type Validable ¶
type Validable interface { // Validate will be used if no ValidateWithInternalError is defined on a document // It is not useful to have both defined on a document, only ValidationWithInternalError // would be used in this case Validate(ctx context.Context) *errors.ValidationErrors // ValidateWithInternalError will be used in priority if defined on a document // It will be called for all modifying operations (Create, Save, Update) // If it returns an internal error, the validation error will be nil. ValidateWithInternalError(ctx context.Context) (*errors.ValidationErrors, error) }
Click to show internal directories.
Click to hide internal directories.