mirror of
https://github.com/mainnika/mongox-go-driver.git
synced 2026-05-22 15:53:36 +00:00
ObjectId base might be empty
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
package base
|
||||
|
||||
import (
|
||||
"github.com/mainnika/mongox-go-driver/mongox"
|
||||
"github.com/mongodb/mongo-go-driver/bson/primitive"
|
||||
)
|
||||
|
||||
var _ mongox.BaseObjectID = &ObjectID{}
|
||||
|
||||
// ObjectID is a structure with objectId as an _id field
|
||||
type ObjectID struct {
|
||||
ID primitive.ObjectID `bson:"_id" json:"_id"`
|
||||
ID primitive.ObjectID `bson:"_id,omitempty" json:"_id,omitempty"`
|
||||
}
|
||||
|
||||
// GetID returns an _id
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
package mongox
|
||||
|
||||
import (
|
||||
"github.com/mongodb/mongo-go-driver/bson/primitive"
|
||||
)
|
||||
|
||||
type Saver interface {
|
||||
Save(db *Database) error
|
||||
}
|
||||
@@ -11,3 +15,8 @@ type Deleter interface {
|
||||
type Loader interface {
|
||||
Load(db *Database, filters ...interface{}) error
|
||||
}
|
||||
|
||||
type BaseObjectID interface {
|
||||
GetID() primitive.ObjectID
|
||||
SetID(id primitive.ObjectID)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user