type ExampleModel struct {
mongol.BaseDocument `bson:",inline"`
// Default fields from BaseDocument
//
// ID primitive.ObjectID `json:"id,omitempty" bson:"_id,omitempty"`
// CreatedAt time.Time `json:"created_at" bson:"created_at"`
// UpdatedAt time.Time `json:"updated_at" bson:"updated_at"`
Title string `json:"title,omitempty" bson:"title,omitempty"`
}
storage, connErr = NewBaseCollection(context.TODO(), mongoURI, mongoDBName, mongoCollectionName)
m := &ExampleModel{}
id, saveErr := storage.InsertOne(context.TODO(), m)
newM := &ExampleModel{}
err := storage.GetOneByFilter(
context.TODO(),
NewFilterBuilder().EqualTo("_id", m.ID).GetQuery(),
newM,
)
if err != nil {
fmt.Printf("%#v", newM)
}
make test-all
MONGODB_URI=mongodb://localhost:27017 go test -a -v ./...