Documentation
¶
Index ¶
- Variables
- type BulkCreateDto
- type BulkDeleteDto
- type Controller
- func (x *Controller) BulkCreate(ctx context.Context, c *app.RequestContext)
- func (x *Controller) BulkDelete(ctx context.Context, c *app.RequestContext)
- func (x *Controller) Create(ctx context.Context, c *app.RequestContext)
- func (x *Controller) Delete(ctx context.Context, c *app.RequestContext)
- func (x *Controller) Find(ctx context.Context, c *app.RequestContext)
- func (x *Controller) FindById(ctx context.Context, c *app.RequestContext)
- func (x *Controller) FindOne(ctx context.Context, c *app.RequestContext)
- func (x *Controller) Replace(ctx context.Context, c *app.RequestContext)
- func (x *Controller) Size(ctx context.Context, c *app.RequestContext)
- func (x *Controller) Sort(ctx context.Context, c *app.RequestContext)
- func (x *Controller) Update(ctx context.Context, c *app.RequestContext)
- func (x *Controller) UpdateById(ctx context.Context, c *app.RequestContext)
- type CreateDto
- type DSL
- type DeleteDto
- type FindByIdDto
- type FindDto
- type FindOneDto
- type M
- type Option
- type PublishDto
- type ReplaceDto
- type Service
- func (x *Service) BulkCreate(ctx context.Context, name string, docs []interface{}) (r interface{}, err error)
- func (x *Service) BulkDelete(ctx context.Context, name string, filter M) (r interface{}, err error)
- func (x *Service) Create(ctx context.Context, name string, doc M) (r interface{}, err error)
- func (x *Service) Delete(ctx context.Context, name string, id primitive.ObjectID) (r interface{}, err error)
- func (x *Service) Find(ctx context.Context, name string, filter M, option *options.FindOptions) (data []M, err error)
- func (x *Service) FindOne(ctx context.Context, name string, filter M, option *options.FindOneOptions) (data M, err error)
- func (x *Service) Load(ctx context.Context) (err error)
- func (x *Service) Projection(name string, keys []string) (result bson.M)
- func (x *Service) Publish(ctx context.Context, name string, dto PublishDto) (err error)
- func (x *Service) Replace(ctx context.Context, name string, id primitive.ObjectID, doc M) (r interface{}, err error)
- func (x *Service) Size(ctx context.Context, name string, filter M) (_ int64, err error)
- func (x *Service) Sort(ctx context.Context, name string, ids []primitive.ObjectID) (r interface{}, err error)
- func (x *Service) Transform(data M, format M) (err error)
- func (x *Service) Update(ctx context.Context, name string, filter M, update M) (r interface{}, err error)
- func (x *Service) UpdateById(ctx context.Context, name string, id primitive.ObjectID, update M) (r interface{}, err error)
- type SizeDto
- type SortDto
- type UpdateByIdDto
- type UpdateDto
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type BulkCreateDto ¶
type BulkCreateDto struct { Collection string `path:"collection,required" vd:"regexp('^[a-z_]+$');msg:'the collection name must be lowercase letters with underscores'"` Data []M `json:"data,required" vd:"len($)>0 && range($,len(#v)>0);msg:'batch documents cannot have empty data'"` Format M `json:"format"` }
type BulkDeleteDto ¶
type Controller ¶
type Controller struct {
Service *Service
}
func (*Controller) BulkCreate ¶
func (x *Controller) BulkCreate(ctx context.Context, c *app.RequestContext)
BulkCreate @router /:collection/bulk-create [POST]
func (*Controller) BulkDelete ¶
func (x *Controller) BulkDelete(ctx context.Context, c *app.RequestContext)
BulkDelete @router /:collection/bulk-delete [POST]
func (*Controller) Create ¶
func (x *Controller) Create(ctx context.Context, c *app.RequestContext)
Create @router /:collection [POST]
func (*Controller) Delete ¶
func (x *Controller) Delete(ctx context.Context, c *app.RequestContext)
Delete @router /:collection/:id [DELETE]
func (*Controller) Find ¶
func (x *Controller) Find(ctx context.Context, c *app.RequestContext)
Find @router /:collection [GET]
func (*Controller) FindById ¶
func (x *Controller) FindById(ctx context.Context, c *app.RequestContext)
FindById @router /:collection/:id [GET]
func (*Controller) FindOne ¶
func (x *Controller) FindOne(ctx context.Context, c *app.RequestContext)
FindOne @router /:collection/_one [GET]
func (*Controller) Replace ¶
func (x *Controller) Replace(ctx context.Context, c *app.RequestContext)
Replace @router /:collection/:id [PUT]
func (*Controller) Size ¶
func (x *Controller) Size(ctx context.Context, c *app.RequestContext)
Size @router /:collection/_size [GET]
func (*Controller) Sort ¶
func (x *Controller) Sort(ctx context.Context, c *app.RequestContext)
Sort @router /:collection/sort [POST]
func (*Controller) Update ¶
func (x *Controller) Update(ctx context.Context, c *app.RequestContext)
Update @router /:collection [PATCH]
func (*Controller) UpdateById ¶
func (x *Controller) UpdateById(ctx context.Context, c *app.RequestContext)
UpdateById @router /:collection/:id [PATCH]
type DSL ¶
type DSL struct { Namespace string Db *mongo.Database DynamicValues *kv.DynamicValues Js nats.JetStreamContext }
type FindByIdDto ¶
type FindByIdDto struct { Collection string `path:"collection,required" vd:"regexp('^[a-z_]+$');msg:'the collection name must be lowercase letters with underscores'"` Id string `path:"id,required" vd:"mongoId($);msg:'the document id must be an ObjectId'"` Keys []string `query:"keys" vd:"range($,regexp('^[a-z_]+$',#v));msg:'the projection rules are not standardized'"` }
type FindDto ¶
type FindDto struct { Collection string `path:"collection,required" vd:"regexp('^[a-z_]+$');msg:'the collection name must be lowercase letters with underscores'"` Pagesize int64 `header:"x-pagesize" vd:"$>=0 && $<=1000;msg:'the number of pages must be between 1 and 1000'"` Page int64 `header:"x-page" vd:"$>=0;msg:'the page number must be greater than 0'"` Filter M `query:"filter"` Format M `query:"format"` Sort []string `query:"sort" vd:"range($,regexp('^[a-z_]+:(-1|1)$',#v)));msg:'the collation is not standardized'"` Keys []string `query:"keys" vd:"range($,regexp('^[a-z_]+$',#v));msg:'the projection rules are not standardized'"` }
type FindOneDto ¶
type FindOneDto struct { Collection string `path:"collection,required" vd:"regexp('^[a-z_]+$');msg:'the collection name must be lowercase letters with underscores'"` Filter M `query:"filter,required" vd:"len($)>0;msg:'the filter cannot be empty'"` Format M `query:"format"` Keys []string `query:"keys" vd:"range($,regexp('^[a-z_]+$',#v));msg:'the projection rules are not standardized'"` }
type Option ¶
type Option func(x *DSL)
func SetDatabase ¶
func SetDynamicValues ¶
func SetDynamicValues(v *kv.DynamicValues) Option
func SetJetStream ¶
func SetJetStream(v nats.JetStreamContext) Option
func SetNamespace ¶
type PublishDto ¶
type ReplaceDto ¶
type ReplaceDto struct { Collection string `path:"collection,required" vd:"regexp('^[a-z_]+$');msg:'the collection name must be lowercase letters with underscores'"` Id string `path:"id,required" vd:"mongoId($);msg:'the document id must be an ObjectId'"` Data M `json:"data,required" vd:"len($)>0;msg:'document cannot be empty data'"` Format M `json:"format"` }
type Service ¶
type Service struct {
*DSL
}
func (*Service) BulkCreate ¶
func (*Service) BulkDelete ¶
func (*Service) Projection ¶
type UpdateByIdDto ¶
type UpdateByIdDto struct { Collection string `path:"collection,required" vd:"regexp('^[a-z_]+$');msg:'the collection name must be lowercase letters with underscores'"` Id string `path:"id,required" vd:"mongoId($);msg:'the document id must be an ObjectId'"` Data M `json:"data,required" vd:"len($)>0;msg:'the update cannot be empty'"` Format M `json:"format"` }
type UpdateDto ¶
type UpdateDto struct { Collection string `path:"collection" vd:"regexp('^[a-z_]+$');msg:'the collection name must be lowercase letters with underscores'"` Filter M `query:"filter,required" vd:"len($)>0;msg:'the filter cannot be empty'"` FFormat M `query:"format"` Data M `json:"data,required" vd:"len($)>0;msg:'the update cannot be empty'"` DFormat M `json:"format"` }
Click to show internal directories.
Click to hide internal directories.