options

package
v0.0.0-beta.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 17, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FindOneOptions

type FindOneOptions struct {
	*options.FindOneOptions
	*QueryOptions
	*HookOptions
}

FindOneOptions represents options that can be used to configure a FindOne operation.

func FindOne

func FindOne() *FindOneOptions

FindOne returns a new FindOneOptions.

type FindOptions

type FindOptions struct {
	*options.FindOptions
	*QueryOptions
	*HookOptions
}

FindOptions represents options that can be used to configure a Find operation.

func Find

func Find() *FindOptions

Find returns a new FindOptions.

type HookOptions

type HookOptions struct {
	// DisableAllHooks disables all hooks, ignoring other hook options.
	DisableAllHooks *bool

	// DisableBeforeHooks disables all before hooks.
	DisableBeforeHooks *bool

	// DisableAfterHooks disables all after hooks.
	DisableAfterHooks *bool

	// This stores the names of the hooks that are disabled.
	// Example: []string{"BeforeCreate", "AfterCreate"}
	DisabledHooks *[]string
}

HookOptions represents the options for configuring how hook runs on a single operation.

func Hook

func Hook() *HookOptions

Hook returns a new HookOptions instance.

func (*HookOptions) SetDisableAfterHooks

func (opts *HookOptions) SetDisableAfterHooks(disable bool) *HookOptions

SetDisableAfterHooks sets the `DisableAfterHooks` option.

func (*HookOptions) SetDisableAllHooks

func (opts *HookOptions) SetDisableAllHooks(disable bool) *HookOptions

SetDisableAllHooks sets the `DisableAllHooks` option.

func (*HookOptions) SetDisableBeforeHooks

func (opts *HookOptions) SetDisableBeforeHooks(disable bool) *HookOptions

SetDisableBeforeHooks sets the `DisableBeforeHooks` option.

func (*HookOptions) SetDisabledHooks

func (opts *HookOptions) SetDisabledHooks(hooks ...string) *HookOptions

SetDisabledHooks sets the `DisabledHooks` option.

type InsertManyOptions

type InsertManyOptions struct {
	*options.InsertManyOptions
	*HookOptions
}

InsertManyOptions represents the options for inserting many document.

func InsertMany

func InsertMany() *InsertManyOptions

InsertOne returns a new InsertOneOptions.

type InsertOneOptions

type InsertOneOptions struct {
	*options.InsertOneOptions
	*HookOptions
}

InsertOneOptions represents the options for inserting a document.

func InsertOne

func InsertOne() *InsertOneOptions

InsertOne returns a new InsertOneOptions.

type PopulateOption

type PopulateOption = []*PopulateOptions

type PopulateOptions

type PopulateOptions struct {
	// Path to populate.
	Path *string
	// Optional query conditions to match.
	Match *bson.M
	// Model to use for population.
	Collection *string
	// Optional query options. Only sort, skip, limit and projections are used.
	Options *options.FindOptions
	// Paths to populate on the populated doc.
	Populate *[]*PopulateOptions
	// Schema the populated doc is associated with, default is bson.M.
	Schema interface{}
	// Override the schema-level `LocalField` option for this individual `populate()` call.
	LocalField *string
	// Override the schema-level `ForeignField` option for this individual `populate()` call.
	// Default: "_id"
	ForeignField *string
	// If true `path` is to a document, or `nil` if no document was found.
	// If false `path` is set to an array, which will be empty if no documents are found.
	// Default: true
	OnlyOne *bool
}

PopulateOptions represents the options for populating a path on a document.

func Populate

func Populate() *PopulateOptions

Populate returns a new PopulateOptions with `OnlyOne` set to `true`.

func (*PopulateOptions) SetCollection

func (pop *PopulateOptions) SetCollection(coll string) *PopulateOptions

SetCollection sets the `Collection` option.

func (*PopulateOptions) SetForeignField

func (pop *PopulateOptions) SetForeignField(foreignField string) *PopulateOptions

SetForeignField sets the `ForeignField` option.

func (*PopulateOptions) SetLocalField

func (pop *PopulateOptions) SetLocalField(localField string) *PopulateOptions

SetLocalField sets the `LocalField` option.

func (*PopulateOptions) SetMatch

func (pop *PopulateOptions) SetMatch(match bson.M) *PopulateOptions

SetMatch sets the `Match` option.

func (*PopulateOptions) SetOnlyOne

func (pop *PopulateOptions) SetOnlyOne(onlyOne bool) *PopulateOptions

SetOnlyOne sets the `OnlyOne` option.

func (*PopulateOptions) SetOptions

func (pop *PopulateOptions) SetOptions(options *options.FindOptions) *PopulateOptions

SetOptions sets the `Options` option.

func (*PopulateOptions) SetPath

func (pop *PopulateOptions) SetPath(path string) *PopulateOptions

SetPath sets the `Path` option.

func (*PopulateOptions) SetPopulate

func (pop *PopulateOptions) SetPopulate(populate ...*PopulateOptions) *PopulateOptions

SetPopulate sets the `Populate` option.

func (*PopulateOptions) SetSchema

func (pop *PopulateOptions) SetSchema(schema interface{}) *PopulateOptions

SetSchema sets the `Schema` option.

type QueryOptions

type QueryOptions struct {
	*PopulateOption
}

QueryOptions represents the options for querying documents.

func MergeFindOneOptions

func MergeFindOneOptions(opts ...*FindOneOptions) (*QueryOptions, *options.FindOneOptions)

MergeFindOneOptions combines the given FindOneOptions instances into a single FindOneOptions in a last-one-wins fashion. Deprecated: Use single struct options.

func MergeFindOptions

func MergeFindOptions(opts ...*FindOptions) (*QueryOptions, *options.FindOptions)

MergeFindOptions combines the given FindOptions instances into a single FindOptions in a last-one-wins fashion. Deprecated: Use single struct options.

func MergeInsertManyOptions

func MergeInsertManyOptions(
	opts ...*InsertManyOptions,
) (*QueryOptions, *options.InsertManyOptions)

MergeInsertManyOptions combines the given InsertManyOptions instances into a single InsertManyOptions in a last-one-wins fashion. Deprecated: Use single struct options.

func MergeInsertOneOptions

func MergeInsertOneOptions(opts ...*InsertOneOptions) (*QueryOptions, *options.InsertOneOptions)

MergeInsertOneOptions combines the given InsertOneOptions instances into a single InsertOneOptions in a last-one-wins fashion. Deprecated: Use single struct options.

func MergeQueryOptions

func MergeQueryOptions(opts ...*QueryOptions) *QueryOptions

func Query

func Query() *QueryOptions

Query returns a new QueryOptions.

func (*QueryOptions) SetPopulate

func (qo *QueryOptions) SetPopulate(populate ...*PopulateOptions) *QueryOptions

SetPopulate sets the `Populate` option.

type UpdateOptions

type UpdateOptions struct {
	*options.UpdateOptions
	*HookOptions
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL