Documentation
¶
Index ¶
- type Entity
- type EntityMarshaler
- type Field
- type MongoEntityRepository
- func (mer *MongoEntityRepository) CreateEntity(ctx context.Context, entity *domain.Entity) (*domain.Entity, error)
- func (repo *MongoEntityRepository) GetEntityById(ctx context.Context, entityId string) (*domain.Entity, error)
- func (mer *MongoEntityRepository) GetEntityByName(ctx context.Context, entityName string) (*domain.Entity, error)
- type Rule
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Entity ¶
type Entity struct { // TODO: by using the mongo.ObjectID wrapper // the ID in the database is not being set properly. // It assigns a BYNARY // How can this be solved if we want to use the wrapper? ID primitive.ObjectID `bson:"_id,omitempty"` Name string `bson:"name"` SingularName string `bson:"singular_name"` PluralName string `bson:"plural_name"` Fields []Field `bson:"fields"` Collection string `bson:"collection"` }
Entity is a specific definition of an object/entity/thing inside a domain in Mongo
type EntityMarshaler ¶
type EntityMarshaler interface { // MarshalEntity encodes a domain entity model to a mongo entity model MarshalEntity(entity *domain.Entity) (*Entity, error) // UnmarshalEntity decodes a mongo entity model to a domain entity model UnmarshalEntity(ent *Entity) (*domain.Entity, error) }
EntityMarshaler decodes/encodes domain entity model from/to mongo entity model
func NewEntityMarshaler ¶
func NewEntityMarshaler() EntityMarshaler
NewEntityMarshaler returns a new instance of EntityMarshaler
type Field ¶
type Field struct { Type string `bson:"type"` Name string `bson:"name"` Label string `bson:"label"` Help string `bson:"help"` Placeholder string `bson:"placeholder"` Rules []Rule `bson:"rules"` }
Field defines a representation for every field of an entity in Mongo
type MongoEntityRepository ¶
type MongoEntityRepository struct {
// contains filtered or unexported fields
}
MongoEntityRepository is the repository to manage entities in Mongo
func NewMongoEntityRepository ¶
func NewMongoEntityRepository( entityMarshaler EntityMarshaler, mongoClient mongo.MongoClient, ) (*MongoEntityRepository, error)
NewMongoEntityRepository creates an instace of MongoEntityRepository
func (*MongoEntityRepository) CreateEntity ¶
func (mer *MongoEntityRepository) CreateEntity( ctx context.Context, entity *domain.Entity, ) (*domain.Entity, error)
CreateEntity creates an entity with fields and rules in Mongo
func (*MongoEntityRepository) GetEntityById ¶
func (repo *MongoEntityRepository) GetEntityById( ctx context.Context, entityId string, ) (*domain.Entity, error)
GetEntityById returns one single entity defined by its id
func (*MongoEntityRepository) GetEntityByName ¶
func (mer *MongoEntityRepository) GetEntityByName( ctx context.Context, entityName string, ) (*domain.Entity, error)
GetEntityByName returns one single entity defined by its name
Click to show internal directories.
Click to hide internal directories.