Documentation ¶
Index ¶
- func ConfigureMongoClient(app *feathers.App, config map[string]interface{}) error
- func MapDecodeMongo() mapstructure.DecodeHookFunc
- func MongoKeys(fields ...string) feathers.Hook
- func NormalizeObjectId(id interface{}) primitive.ObjectID
- func ObjectIDEquals(id interface{}, id2 interface{}) bool
- type Document
- type IdDocument
- type Service
- func (f *Service) Collection() (*mongo.Collection, bool)
- func (f *Service) Create(ctx context.Context, data map[string]interface{}, params feathers.Params) (interface{}, error)
- func (f *Service) Find(ctx context.Context, params feathers.Params) (interface{}, error)
- func (f *Service) Get(ctx context.Context, id string, params feathers.Params) (interface{}, error)
- func (f *Service) Patch(ctx context.Context, id string, data map[string]interface{}, ...) (interface{}, error)
- func (f *Service) Remove(ctx context.Context, id string, params feathers.Params) (interface{}, error)
- func (f *Service) Update(ctx context.Context, id string, data map[string]interface{}, ...) (interface{}, error)
- type TimestampDoc
- type Timestampable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfigureMongoClient ¶
ConfigureMongoClient configures a mongo client for usage whith the mongoservice
client is saved to `mongoClient` key in app config
func MapDecodeMongo ¶
func MapDecodeMongo() mapstructure.DecodeHookFunc
func NormalizeObjectId ¶
func ObjectIDEquals ¶
func ObjectIDEquals(id interface{}, id2 interface{}) bool
Types ¶
type Document ¶
type Document struct {
ID primitive.ObjectID `bson:"_id" mapstructure:"_id,omitempty" json:"_id" ts_type:"string"`
}
func NewDocument ¶
func NewDocument() *Document
func (*Document) GenerateID ¶
func (d *Document) GenerateID()
type IdDocument ¶
type IdDocument interface { GenerateID() IDIsZero() bool }
type Service ¶
type Service struct { *feathers.BaseService *feathers.ModelService CollectionName string // contains filtered or unexported fields }
Service for mongodb which offers model validation. Use `NewService` for new instance. (another service is supposed to extend from this)
func NewService ¶
NewService creates a new mongo service struct
func (*Service) Collection ¶
func (f *Service) Collection() (*mongo.Collection, bool)
type TimestampDoc ¶
type TimestampDoc struct { CreatedAt primitive.DateTime `bson:"createdAt" mapstructure:"createdAt" json:"createdAt"` UpdatedAt primitive.DateTime `bson:"updatedAt" mapstructure:"updatedAt" json:"updatedAt"` }
func (*TimestampDoc) SetCreatedAt ¶
func (td *TimestampDoc) SetCreatedAt()
func (*TimestampDoc) SetUpdatedAt ¶
func (td *TimestampDoc) SetUpdatedAt()
type Timestampable ¶
type Timestampable interface { SetCreatedAt() SetUpdatedAt() }
Click to show internal directories.
Click to hide internal directories.