Documentation ¶
Index ¶
- 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
- type ValidationErrors
- type ValidationErrorsBuilder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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(ctx context.Context) *ValidationErrors
}
type ValidationErrors ¶
type ValidationErrors = errors.ValidationErrors
ValidationErrors is a type alias of errors.ValidationErrors. It is defined to keep retro-compatibility
type ValidationErrorsBuilder ¶
type ValidationErrorsBuilder = errors.ValidationErrorsBuilder
ValidationErrorsBuilder is a type alias of errors.ValidationErrorsBuilder. It is defined to keep retro-compatibility
func NewValidationErrorsBuilder ¶
func NewValidationErrorsBuilder() *ValidationErrorsBuilder
NewValidationErrors return an empty ValidationErrors struct
Click to show internal directories.
Click to hide internal directories.