mgutil

package
v0.0.0-...-6f9dc6e Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2023 License: MIT Imports: 3 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 Set

func Set(v interface{}) bson.M

Set returns a $set update document.

func SetOnInsert

func SetOnInsert(v interface{}) bson.M

SetOnInsert returns a $setOnInsert 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 ObjID

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

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