Documentation ¶
Index ¶
- Constants
- Variables
- func ConvertObjID(data bson.M) (err error)
- func DB() *mongo.Database
- func GetByID(idStr string, obj *CollectionModel) (err error)
- func InitDAO(url string, databaseName string) error
- func ObjectID(id string) primitive.ObjectID
- func SaveOrUpdate(obj CollectionModel) (err error)
- type CollectionModel
- type CollectionWrap
- func (cw *CollectionWrap) Count(count *int64, filters *bson.M) *CollectionWrap
- func (cw *CollectionWrap) DeleteByID(idStr string) *CollectionWrap
- func (cw *CollectionWrap) DeleteManyByIDs(idStrs []string) *CollectionWrap
- func (cw *CollectionWrap) FindOneWithBson(object interface{}, filter *bson.M, options *options.FindOptions) *CollectionWrap
- func (cw *CollectionWrap) FindWithBson(objects interface{}, filter *bson.M, options *options.FindOptions) *CollectionWrap
- func (cw *CollectionWrap) GetByID(idStr string, object interface{}) *CollectionWrap
- func (cw *CollectionWrap) SaveOrUpdate(object interface{}) *CollectionWrap
- func (cw *CollectionWrap) UpdateManyByID(idStrs []string, updateBsonM *bson.M) *CollectionWrap
- type GModle
- type PageInfo
- type QueryInfo
- type ResultInfo
Constants ¶
View Source
const OBJECTID_STR_MAX = "ffffffff0000000000000000"
View Source
const OBJECTID_STR_MIN = "000000000000000000000000"
Variables ¶
View Source
var DefaultPageSize int64 = 10
View Source
var ErrorNoMatchData = errors.New("no match data")
View Source
var ObjectID_MAX primitive.ObjectID
View Source
var ObjectID_MIN primitive.ObjectID
Functions ¶
func ConvertObjID ¶ added in v0.4.0
func GetByID ¶ added in v0.4.4
func GetByID(idStr string, obj *CollectionModel) (err error)
func SaveOrUpdate ¶ added in v0.4.1
func SaveOrUpdate(obj CollectionModel) (err error)
Types ¶
type CollectionModel ¶
type CollectionModel interface {
CollectionName() string
}
type CollectionWrap ¶
type CollectionWrap struct { *mongo.Collection ModelType reflect.Type Error error }
func Model ¶
func Model(obj interface{}) *CollectionWrap
func (*CollectionWrap) Count ¶ added in v0.3.4
func (cw *CollectionWrap) Count(count *int64, filters *bson.M) *CollectionWrap
func (*CollectionWrap) DeleteByID ¶
func (cw *CollectionWrap) DeleteByID(idStr string) *CollectionWrap
DeleteByID delete the object whose ID's string is idStr
func (*CollectionWrap) DeleteManyByIDs ¶
func (cw *CollectionWrap) DeleteManyByIDs(idStrs []string) *CollectionWrap
func (*CollectionWrap) FindOneWithBson ¶
func (cw *CollectionWrap) FindOneWithBson(object interface{}, filter *bson.M, options *options.FindOptions) *CollectionWrap
func (*CollectionWrap) FindWithBson ¶
func (cw *CollectionWrap) FindWithBson(objects interface{}, filter *bson.M, options *options.FindOptions) *CollectionWrap
FindWithBson find records into (&slice) with options
func (*CollectionWrap) GetByID ¶ added in v0.3.3
func (cw *CollectionWrap) GetByID(idStr string, object interface{}) *CollectionWrap
get the object by idStr [object] must be a pointer to a model
func (*CollectionWrap) SaveOrUpdate ¶
func (cw *CollectionWrap) SaveOrUpdate(object interface{}) *CollectionWrap
SaveOrUpdate object must be a pointer to a model
func (*CollectionWrap) UpdateManyByID ¶
func (cw *CollectionWrap) UpdateManyByID(idStrs []string, updateBsonM *bson.M) *CollectionWrap
Click to show internal directories.
Click to hide internal directories.