Documentation ¶
Index ¶
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, dbClient database.DatabaseClient, ) (*MongoEntityRepository, error)
NewMongoEntityRepository creates an instace of MongoEntityRepository
func (*MongoEntityRepository) CreateEntity ¶
func (repo *MongoEntityRepository) CreateEntity( ctx context.Context, entity *domain.Entity, ) (*domain.Entity, error)
CreateEntity creates an entity with fields and rules in Mongo
func (*MongoEntityRepository) GetEntityByName ¶
func (repo *MongoEntityRepository) GetEntityByName( ctx context.Context, entityName string, ) (*domain.Entity, error)
GetEntityByName returns one single entity defined by its name
type MongoRecordRepository ¶ added in v1.3.0
type MongoRecordRepository struct {
// contains filtered or unexported fields
}
RecordRepository defines the repository that stores, modifies and deletes record in Mongo
func NewMongoRecordRepository ¶ added in v1.3.0
func NewMongoRecordRepository( dbClient database.DatabaseClient, ) (*MongoRecordRepository, error)
NewMongoRecordRepository creates an instace of MongoRecordRepository