mgutil

package
v0.0.0-...-20002e4 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IDFieldName        = "_id"
	UpdatedAtFieldName = "updatedat"
)

Common field names.

Variables

NewObjID generates a new object id.

View Source
var UpdatedAt = func() int64 {
	return time.Now().UnixNano()
}

UpdatedAt returns a value suitable for UpdatedAt field.

Functions

func NewObjIDWithValue

func NewObjIDWithValue(id fmt.Stringer)

NewObjIDWithValue sets id for next objectID generation.

func Set

func Set(v interface{}) bson.M

Set returns a $set update document.

func ZeroOrDoesNotExist

func ZeroOrDoesNotExist(field string, zero interface{}) bson.M

ZeroOrDoesNotExist generates a filter expression with field equal to zero or field does not exist.

Types

type IDField

type IDField struct {
	ID primitive.ObjectID `bson:"_id"`
}

IDField defines the object id field.

type UpdatedAtField

type UpdatedAtField struct {
	UpdatedAt int64 `bson:"updatedat"`
}

UpdatedAtField defines the updatedat field.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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