mongodoc

package
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 10, 2022 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func And added in v0.6.0

func And(filter interface{}, key string, f interface{}) interface{}

func NewDatasetSchemas

func NewDatasetSchemas(datasetSchemas []*dataset.Schema, f scene.IDList) ([]interface{}, []string)

func NewDatasets

func NewDatasets(datasets []*dataset.Dataset, f scene.IDList) ([]interface{}, []string)

func NewLayers

func NewLayers(layers layer.List, f scene.IDList) ([]interface{}, []string)

func NewProperties

func NewProperties(properties []*property.Property, f scene.IDList) ([]interface{}, []string)

func NewPropertySchemas

func NewPropertySchemas(ps []*property.Schema, f scene.IDList) ([]interface{}, []string)

func NewTags

func NewTags(tags []*tag.Tag, f scene.IDList) ([]interface{}, []string)

func ToModelInfobox

func ToModelInfobox(ib *LayerInfoboxDocument) (*layer.Infobox, error)

Types

type AssetConsumer

type AssetConsumer struct {
	Rows []*asset.Asset
}

func (*AssetConsumer) Consume

func (c *AssetConsumer) Consume(raw bson.Raw) error

type AssetDocument

type AssetDocument struct {
	ID          string
	CreatedAt   time.Time
	Team        string
	Name        string
	Size        int64
	URL         string
	ContentType string
}

func NewAsset

func NewAsset(asset *asset.Asset) (*AssetDocument, string)

func (*AssetDocument) Model

func (d *AssetDocument) Model() (*asset.Asset, error)

type Auth added in v0.6.0

type Auth struct {
	Cert string
	Key  string
}

type AuthRequestConsumer added in v0.6.0

type AuthRequestConsumer struct {
	Rows []*auth.Request
}

func (*AuthRequestConsumer) Consume added in v0.6.0

func (a *AuthRequestConsumer) Consume(raw bson.Raw) error

type AuthRequestDocument added in v0.6.0

type AuthRequestDocument struct {
	ID            string
	ClientID      string
	Subject       string
	Code          string
	State         string
	ResponseType  string
	Scopes        []string
	Audiences     []string
	RedirectURI   string
	Nonce         string
	CodeChallenge *CodeChallengeDocument
	CreatedAt     time.Time
	AuthorizedAt  *time.Time
}

func NewAuthRequest added in v0.6.0

func NewAuthRequest(req *auth.Request) (*AuthRequestDocument, string)

func (*AuthRequestDocument) Model added in v0.6.0

func (d *AuthRequestDocument) Model() (*auth.Request, error)

type BatchConsumer

type BatchConsumer struct {
	Size     int
	Rows     []bson.Raw
	Callback func([]bson.Raw) error
}

func (*BatchConsumer) Consume

func (c *BatchConsumer) Consume(raw bson.Raw) error

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(database string, c *mongo.Client) *Client

func (*Client) BeginTransaction added in v0.3.0

func (c *Client) BeginTransaction() (repo.Tx, error)

func (*Client) Collection

func (c *Client) Collection(col string) *mongo.Collection

func (*Client) Count

func (c *Client) Count(ctx context.Context, col string, filter interface{}) (int64, error)

func (*Client) CreateIndex

func (c *Client) CreateIndex(ctx context.Context, col string, keys []string) []string

func (*Client) CreateUniqueIndex added in v0.6.0

func (c *Client) CreateUniqueIndex(ctx context.Context, col string, keys, uniqueKeys []string) []string

func (*Client) Find

func (c *Client) Find(ctx context.Context, col string, filter interface{}, consumer Consumer) error

func (*Client) FindOne

func (c *Client) FindOne(ctx context.Context, col string, filter interface{}, consumer Consumer) error

func (*Client) Paginate

func (c *Client) Paginate(ctx context.Context, col string, filter interface{}, sort *string, p *Pagination, consumer Consumer) (*usecase.PageInfo, error)

func (*Client) RemoveAll

func (c *Client) RemoveAll(ctx context.Context, col string, f interface{}) error

func (*Client) RemoveOne

func (c *Client) RemoveOne(ctx context.Context, col string, f interface{}) error

func (*Client) SaveAll

func (c *Client) SaveAll(ctx context.Context, col string, ids []string, updates []interface{}) error

func (*Client) SaveOne

func (c *Client) SaveOne(ctx context.Context, col string, id string, replacement interface{}) error

func (*Client) UpdateMany added in v0.5.0

func (c *Client) UpdateMany(ctx context.Context, col string, filter, update interface{}) error

func (*Client) UpdateManyMany added in v0.5.0

func (c *Client) UpdateManyMany(ctx context.Context, col string, updates []Update) error

func (*Client) WithCollection

func (c *Client) WithCollection(col string) *ClientCollection

type ClientCollection

type ClientCollection struct {
	Client         *Client
	CollectionName string
}

func (*ClientCollection) Collection

func (c *ClientCollection) Collection() *mongo.Collection

func (*ClientCollection) Count

func (c *ClientCollection) Count(ctx context.Context, filter interface{}) (int64, error)

func (*ClientCollection) CreateIndex

func (c *ClientCollection) CreateIndex(ctx context.Context, keys []string) []string

func (*ClientCollection) CreateUniqueIndex added in v0.6.0

func (c *ClientCollection) CreateUniqueIndex(ctx context.Context, keys, uniqueKeys []string) []string

func (*ClientCollection) Find

func (c *ClientCollection) Find(ctx context.Context, filter interface{}, consumer Consumer) error

func (*ClientCollection) FindOne

func (c *ClientCollection) FindOne(ctx context.Context, filter interface{}, consumer Consumer) error

func (*ClientCollection) Paginate

func (c *ClientCollection) Paginate(ctx context.Context, filter interface{}, sort *string, p *usecase.Pagination, consumer Consumer) (*usecase.PageInfo, error)

func (*ClientCollection) RemoveAll

func (c *ClientCollection) RemoveAll(ctx context.Context, f interface{}) error

func (*ClientCollection) RemoveOne

func (c *ClientCollection) RemoveOne(ctx context.Context, f interface{}) error

func (*ClientCollection) SaveAll

func (c *ClientCollection) SaveAll(ctx context.Context, ids []string, updates []interface{}) error

func (*ClientCollection) SaveOne

func (c *ClientCollection) SaveOne(ctx context.Context, id string, replacement interface{}) error

func (*ClientCollection) UpdateMany added in v0.5.0

func (c *ClientCollection) UpdateMany(ctx context.Context, filter interface{}, update interface{}) error

func (*ClientCollection) UpdateManyMany added in v0.5.0

func (c *ClientCollection) UpdateManyMany(ctx context.Context, updates []Update) error

type CodeChallengeDocument added in v0.6.0

type CodeChallengeDocument struct {
	Challenge string
	Method    string
}

type ConfigDocument added in v0.3.0

type ConfigDocument struct {
	Migration int64
	Auth      *Auth
}

func NewConfig added in v0.3.0

func NewConfig(c config.Config) ConfigDocument

func (*ConfigDocument) Model added in v0.3.0

func (c *ConfigDocument) Model() *config.Config

type Consumer

type Consumer interface {
	// Consume で渡されたrawの参照をフィールドに持ってはいけません
	// MUST NOT HAVE A ROW REFERENCE PASSED BY Consume METHOD IN THE FIELD
	Consume(raw bson.Raw) error
}

type DatasetBatchConsumer

type DatasetBatchConsumer struct {
	Size     int
	Callback func([]*dataset.Dataset) error
	// contains filtered or unexported fields
}

func (*DatasetBatchConsumer) Consume

func (c *DatasetBatchConsumer) Consume(raw bson.Raw) error

type DatasetConsumer

type DatasetConsumer struct {
	Rows []*dataset.Dataset
}

func (*DatasetConsumer) Consume

func (c *DatasetConsumer) Consume(raw bson.Raw) error

type DatasetDocument

type DatasetDocument struct {
	ID     string
	Source string
	Schema string
	Fields []*DatasetFieldDocument
	Scene  string
}

func NewDataset

func NewDataset(dataset *dataset.Dataset) (*DatasetDocument, string)

func (*DatasetDocument) Model

func (doc *DatasetDocument) Model() (*dataset.Dataset, error)

type DatasetExtendedDocument

type DatasetExtendedDocument struct {
	DatasetDocument
	Graph []*DatasetExtendedDocument
	Depth int
}

type DatasetFieldDocument

type DatasetFieldDocument struct {
	Field  string
	Type   string
	Value  interface{}
	Source string
}

type DatasetMapConsumer

type DatasetMapConsumer struct {
	Map dataset.Map
}

func (*DatasetMapConsumer) Consume

func (c *DatasetMapConsumer) Consume(raw bson.Raw) error

type DatasetSchemaConsumer

type DatasetSchemaConsumer struct {
	Rows []*dataset.Schema
}

func (*DatasetSchemaConsumer) Consume

func (c *DatasetSchemaConsumer) Consume(raw bson.Raw) error

type DatasetSchemaDocument

type DatasetSchemaDocument struct {
	ID                  string
	Source              string
	Name                string
	Fields              []*DatasetSchemaFieldDocument
	RepresentativeField *string
	Scene               string
	Dynamic             bool
}

func NewDatasetSchema

func NewDatasetSchema(dataset *dataset.Schema) (*DatasetSchemaDocument, string)

func (*DatasetSchemaDocument) Model

func (d *DatasetSchemaDocument) Model() (*dataset.Schema, error)

type DatasetSchemaFieldDocument

type DatasetSchemaFieldDocument struct {
	ID     string
	Name   string
	Type   string
	Source string
}

type FuncConsumer

type FuncConsumer func(raw bson.Raw) error

func (FuncConsumer) Consume

func (c FuncConsumer) Consume(raw bson.Raw) error

type LayerConsumer

type LayerConsumer struct {
	Rows      []*layer.Layer
	GroupRows []*layer.Group
	ItemRows  []*layer.Item
}

func (*LayerConsumer) Consume

func (c *LayerConsumer) Consume(raw bson.Raw) error

type LayerDocument

type LayerDocument struct {
	ID        string
	Name      string
	Visible   bool
	Scene     string
	Plugin    *string
	Extension *string
	Property  *string
	Infobox   *LayerInfoboxDocument
	Item      *LayerItemDocument
	Group     *LayerGroupDocument
	Tags      LayerTagListDocument
}

func NewLayer

func NewLayer(l layer.Layer) (*LayerDocument, string)

func (*LayerDocument) Model

func (d *LayerDocument) Model() (*layer.Item, *layer.Group, error)

func (*LayerDocument) ModelGroup

func (d *LayerDocument) ModelGroup() (*layer.Group, error)

func (*LayerDocument) ModelItem

func (d *LayerDocument) ModelItem() (*layer.Item, error)

type LayerGroupDocument

type LayerGroupDocument struct {
	Layers              []string
	LinkedDatasetSchema *string
	Root                bool
}

type LayerInfoboxDocument

type LayerInfoboxDocument struct {
	Property string
	Fields   []LayerInfoboxFieldDocument
}

type LayerInfoboxFieldDocument

type LayerInfoboxFieldDocument struct {
	ID        string
	Plugin    string
	Extension string
	Property  string
}

type LayerItemDocument

type LayerItemDocument struct {
	LinkedDataset *string
}

type LayerTagDocument added in v0.3.0

type LayerTagDocument struct {
	ID    string
	Group bool
	Tags  []LayerTagDocument
}

func NewLayerTag added in v0.3.0

func NewLayerTag(t layer.Tag) *LayerTagDocument

func (*LayerTagDocument) Model added in v0.3.0

func (d *LayerTagDocument) Model() layer.Tag

type LayerTagListDocument added in v0.3.0

type LayerTagListDocument []LayerTagDocument

func NewLayerTagList added in v0.3.0

func NewLayerTagList(list *layer.TagList) LayerTagListDocument

func (*LayerTagListDocument) Model added in v0.3.0

func (d *LayerTagListDocument) Model() *layer.TagList

type Pagination added in v0.6.0

type Pagination struct {
	Before *string
	After  *string
	First  *int
	Last   *int
}

func PaginationFrom added in v0.6.0

func PaginationFrom(pagination *usecase.Pagination) *Pagination

func (*Pagination) Parameters added in v0.6.0

func (p *Pagination) Parameters() (limit int64, op string, cursor *string, err error)

func (*Pagination) SortDirection added in v0.6.0

func (p *Pagination) SortDirection() int

type PasswordResetDocument added in v0.6.0

type PasswordResetDocument struct {
	Token     string
	CreatedAt time.Time
}

func (*PasswordResetDocument) Model added in v0.6.0

type PluginConsumer

type PluginConsumer struct {
	Rows []*plugin.Plugin
}

func (*PluginConsumer) Consume

func (c *PluginConsumer) Consume(raw bson.Raw) error

type PluginDocument

type PluginDocument struct {
	ID            string
	Name          map[string]string
	Author        string
	Description   map[string]string
	RepositoryURL string
	Extensions    []PluginExtensionDocument
	Schema        *string
	Scene         *string `bson:",omitempty"`
}

func NewPlugin

func NewPlugin(plugin *plugin.Plugin) (*PluginDocument, string)

func (*PluginDocument) Model

func (d *PluginDocument) Model() (*plugin.Plugin, error)

type PluginExtensionDocument

type PluginExtensionDocument struct {
	ID           string
	Type         string
	Name         map[string]string
	Description  map[string]string
	Icon         string
	Schema       string
	Visualizer   string `bson:",omitempty"`
	SingleOnly   bool
	WidgetLayout *WidgetLayoutDocument
}

type ProjectConsumer

type ProjectConsumer struct {
	Rows []*project.Project
}

func (*ProjectConsumer) Consume

func (c *ProjectConsumer) Consume(raw bson.Raw) error

type ProjectDocument

type ProjectDocument struct {
	ID                string
	Archived          bool
	IsBasicAuthActive bool
	BasicAuthUsername string
	BasicAuthPassword string
	UpdatedAt         time.Time
	PublishedAt       time.Time
	Name              string
	Description       string
	Alias             string
	ImageURL          string
	PublicTitle       string
	PublicDescription string
	PublicImage       string
	PublicNoIndex     bool
	Team              string
	Visualizer        string
	PublishmentStatus string
}

func NewProject

func NewProject(project *project.Project) (*ProjectDocument, string)

func (*ProjectDocument) Model

func (d *ProjectDocument) Model() (*project.Project, error)

type PropertyBatchConsumer

type PropertyBatchConsumer struct {
	Size     int
	Callback func([]*property.Property) error
	// contains filtered or unexported fields
}

func (*PropertyBatchConsumer) Consume

func (c *PropertyBatchConsumer) Consume(raw bson.Raw) error

type PropertyConditonDocument

type PropertyConditonDocument struct {
	Field string
	Type  string
	Value interface{}
}

type PropertyConsumer

type PropertyConsumer struct {
	Rows []*property.Property
}

func (*PropertyConsumer) Consume

func (c *PropertyConsumer) Consume(raw bson.Raw) error

type PropertyDocument

type PropertyDocument struct {
	ID           string
	Scene        string
	Schema       string `bson:",omitempty"` // compatibility
	SchemaPlugin string
	SchemaName   string
	Items        []*PropertyItemDocument
}

func NewProperty

func NewProperty(property *property.Property) (*PropertyDocument, string)

func (*PropertyDocument) Model

func (doc *PropertyDocument) Model() (*property.Property, error)

type PropertyFieldDocument

type PropertyFieldDocument struct {
	Field string
	Type  string
	Links []*PropertyLinkDocument
	Value interface{}
}

type PropertyItemDocument

type PropertyItemDocument struct {
	Type        string
	ID          string
	SchemaGroup string
	Groups      []*PropertyItemDocument
	Fields      []*PropertyFieldDocument
}

type PropertyLinkDocument

type PropertyLinkDocument struct {
	Schema  *string
	Dataset *string
	Field   *string
}

type PropertySchemaConsumer

type PropertySchemaConsumer struct {
	Rows []*property.Schema
}

func (*PropertySchemaConsumer) Consume

func (c *PropertySchemaConsumer) Consume(raw bson.Raw) error

type PropertySchemaDocument

type PropertySchemaDocument struct {
	ID             string
	Scene          *string `bson:",omitempty"`
	Version        int
	Groups         []*PropertySchemaGroupDocument
	LinkableFields *PropertyLinkableFieldsDocument
}

func NewPropertySchema

func NewPropertySchema(m *property.Schema) (*PropertySchemaDocument, string)

func (*PropertySchemaDocument) Model

func (doc *PropertySchemaDocument) Model() (*property.Schema, error)

type PropertySchemaFieldChoiceDocument

type PropertySchemaFieldChoiceDocument struct {
	Key   string
	Label map[string]string
}

type PropertySchemaFieldDocument

type PropertySchemaFieldDocument struct {
	ID           string
	Type         string
	Name         map[string]string
	Description  map[string]string
	Prefix       string
	Suffix       string
	DefaultValue interface{}
	UI           *string
	Min          *float64
	Max          *float64
	Choices      []PropertySchemaFieldChoiceDocument
}

type PropertySchemaFieldPointerDocument added in v0.5.0

type PropertySchemaFieldPointerDocument struct {
	SchemaGroupID string
	FieldID       string
}

type PropertySchemaGroupDocument

type PropertySchemaGroupDocument struct {
	ID            string
	Fields        []*PropertySchemaFieldDocument
	List          bool
	IsAvailableIf *PropertyConditonDocument
	Title         map[string]string
}

func (*PropertySchemaGroupDocument) Model added in v0.4.0

type SceneClusterDocument added in v0.3.0

type SceneClusterDocument struct {
	ID       string
	Name     string
	Property string
}

type SceneConsumer

type SceneConsumer struct {
	Rows scene.List
}

func (*SceneConsumer) Consume

func (c *SceneConsumer) Consume(raw bson.Raw) error

type SceneDocument

type SceneDocument struct {
	ID          string
	Project     string
	Team        string
	RootLayer   string
	Widgets     []SceneWidgetDocument
	AlignSystem *WidgetAlignSystemDocument
	Plugins     []ScenePluginDocument
	UpdateAt    time.Time
	Property    string
	Clusters    []SceneClusterDocument
}

func NewScene

func NewScene(scene *scene.Scene) (*SceneDocument, string)

func (*SceneDocument) Model

func (d *SceneDocument) Model() (*scene.Scene, error)

type SceneIDConsumer

type SceneIDConsumer struct {
	Rows []id.SceneID
}

func (*SceneIDConsumer) Consume

func (c *SceneIDConsumer) Consume(raw bson.Raw) error

type SceneIDDocument

type SceneIDDocument struct {
	ID string
}

type SceneLockConsumer

type SceneLockConsumer struct {
	Rows []scene.LockMode
}

func (*SceneLockConsumer) Consume

func (c *SceneLockConsumer) Consume(raw bson.Raw) error

type SceneLockDocument

type SceneLockDocument struct {
	Scene string
	Lock  string
}

func NewSceneLock

func NewSceneLock(sceneID id.SceneID, lock scene.LockMode) *SceneLockDocument

func (*SceneLockDocument) Model

type ScenePluginDocument

type ScenePluginDocument struct {
	Plugin   string
	Property *string
}

type SceneWidgetDocument

type SceneWidgetDocument struct {
	ID        string
	Plugin    string
	Extension string
	Property  string
	Enabled   bool
	Extended  bool
}

type TagConsumer

type TagConsumer struct {
	Rows      []*tag.Tag
	GroupRows []*tag.Group
	ItemRows  []*tag.Item
}

func (*TagConsumer) Consume

func (c *TagConsumer) Consume(raw bson.Raw) error

type TagDocument

type TagDocument struct {
	ID    string
	Label string
	Scene string
	Item  *TagItemDocument
	Group *TagGroupDocument
}

func NewTag

func NewTag(t tag.Tag) (*TagDocument, string)

func (*TagDocument) Model

func (d *TagDocument) Model() (*tag.Item, *tag.Group, error)

func (*TagDocument) ModelGroup

func (d *TagDocument) ModelGroup() (*tag.Group, error)

func (*TagDocument) ModelItem

func (d *TagDocument) ModelItem() (*tag.Item, error)

type TagGroupDocument

type TagGroupDocument struct {
	Tags []string
}

type TagItemDocument

type TagItemDocument struct {
	Parent                *string
	LinkedDatasetFieldID  *string
	LinkedDatasetID       *string
	LinkedDatasetSchemaID *string
}

type TeamConsumer

type TeamConsumer struct {
	Rows user.TeamList
}

func (*TeamConsumer) Consume

func (c *TeamConsumer) Consume(raw bson.Raw) error

type TeamDocument

type TeamDocument struct {
	ID       string
	Name     string
	Members  map[string]TeamMemberDocument
	Personal bool
}

func NewTeam

func NewTeam(team *user.Team) (*TeamDocument, string)

func NewTeams

func NewTeams(teams []*user.Team) ([]*TeamDocument, []string)

func (*TeamDocument) Model

func (d *TeamDocument) Model() (*user.Team, error)

type TeamMemberDocument

type TeamMemberDocument struct {
	Role string
}

type Tx added in v0.3.0

type Tx struct {
	// contains filtered or unexported fields
}

func (*Tx) Commit added in v0.3.0

func (t *Tx) Commit()

func (*Tx) End added in v0.3.0

func (t *Tx) End(ctx context.Context) error

func (*Tx) IsCommitted added in v0.8.0

func (t *Tx) IsCommitted() bool

type Update added in v0.5.0

type Update struct {
	Filter       interface{}
	Update       interface{}
	ArrayFilters []interface{}
}

type UserConsumer

type UserConsumer struct {
	Rows []*user1.User
}

func (*UserConsumer) Consume

func (u *UserConsumer) Consume(raw bson.Raw) error

type UserDocument

type UserDocument struct {
	ID            string
	Name          string
	Email         string
	Auth0Sub      string
	Auth0SubList  []string
	Team          string
	Lang          string
	Theme         string
	Password      []byte
	PasswordReset *PasswordResetDocument
	Verification  *UserVerificationDoc
}

func NewUser

func NewUser(user *user1.User) (*UserDocument, string)

func (*UserDocument) Model

func (d *UserDocument) Model() (*user1.User, error)

type UserVerificationDoc added in v0.6.0

type UserVerificationDoc struct {
	Code       string
	Expiration time.Time
	Verified   bool
}

type WidgetAlignSystemDocument

type WidgetAlignSystemDocument struct {
	Inner *WidgetZoneDocument
	Outer *WidgetZoneDocument
}

func (*WidgetAlignSystemDocument) Model

type WidgetAreaDocument

type WidgetAreaDocument struct {
	WidgetIDs []string
	Align     string
}

func NewWidgetArea

func NewWidgetArea(a *scene.WidgetArea) *WidgetAreaDocument

func (*WidgetAreaDocument) Model

func (a *WidgetAreaDocument) Model() *scene.WidgetArea

type WidgetExtendableDocument

type WidgetExtendableDocument struct {
	Vertically   bool
	Horizontally bool
}

type WidgetLayoutDocument

type WidgetLayoutDocument struct {
	Extendable      *WidgetExtendableDocument
	Extended        bool
	Floating        bool
	DefaultLocation *WidgetLocationDocument
}

func NewWidgetLayout

func NewWidgetLayout(l *plugin.WidgetLayout) *WidgetLayoutDocument

func (*WidgetLayoutDocument) Model

type WidgetLocationDocument

type WidgetLocationDocument struct {
	Zone    string
	Section string
	Area    string
}

func (*WidgetLocationDocument) Model

type WidgetSectionDocument

type WidgetSectionDocument struct {
	Top    *WidgetAreaDocument
	Middle *WidgetAreaDocument
	Bottom *WidgetAreaDocument
}

func NewWidgetSection

func NewWidgetSection(s *scene.WidgetSection) *WidgetSectionDocument

func (*WidgetSectionDocument) Model

type WidgetZoneDocument

type WidgetZoneDocument struct {
	Left   *WidgetSectionDocument
	Center *WidgetSectionDocument
	Right  *WidgetSectionDocument
}

func NewWidgetZone

func NewWidgetZone(z *scene.WidgetZone) *WidgetZoneDocument

func (*WidgetZoneDocument) Model

func (d *WidgetZoneDocument) Model() *scene.WidgetZone

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL