package
0.4.8
Repository: https://github.com/coralproject/shelf.git
Documentation: pkg.go.dev

# README

gallery

import "github.com/coralproject/shelf/internal/ask/form/gallery"

Overview

Index

Package files

gallery.go

Constants

const Collection = "form_galleries"

Collection is the mongo collection where Gallery documents are saved.

Variables

var ErrInvalidID = errors.New("ID is not in it's proper form")

ErrInvalidID occurs when an ID is not in a valid form.

func Create

func Create(context interface{}, db *db.DB, gallery *Gallery) error

Create adds a form gallery based on the form id provided into the MongoDB database collection.

func Delete

func Delete(context interface{}, db *db.DB, id string) error

Delete removes the given Gallery with the ID provided.

func List

func List(context interface{}, db *db.DB, formID string) ([]Gallery, error)

List retrives the form galleries for a given form from the MongoDB database collection.

func Update

func Update(context interface{}, db *db.DB, id string, gallery *Gallery) error

Update updates the form gallery in the MongoDB database collection.

type Answer

type Answer struct {
    SubmissionID    bson.ObjectId       `json:"submission_id" bson:"submission_id" validate:"required"`
    AnswerID        string              `json:"answer_id" bson:"answer_id" validate:"required"`
    Answer          submission.Answer   `json:"answer,omitempty" bson:"-" validate:"-"`
    IdentityAnswers []submission.Answer `json:"identity_answers,omitempty" bson:"-"`
}

Answer describes an answer from a form which has been added to a Gallery.

func (*Answer) Validate

func (a *Answer) Validate() error

Validate checks the Anser value for consistency.

type Gallery

type Gallery struct {
    ID          bson.ObjectId          `json:"id" bson:"_id" validate:"required"`
    FormID      bson.ObjectId          `json:"form_id" bson:"form_id" validate:"required"`
    Headline    string                 `json:"headline" bson:"headline"`
    Description string                 `json:"description" bson:"description"`
    Config      map[string]interface{} `json:"config" bson:"config"`
    Answers     []Answer               `json:"answers" bson:"answers"`
    DateCreated time.Time              `json:"date_created,omitempty" bson:"date_created,omitempty"`
    DateUpdated time.Time              `json:"date_updated,omitempty" bson:"date_updated,omitempty"`
}

Gallery is a Form that has been moved to a shared space.

func AddAnswer

func AddAnswer(context interface{}, db *db.DB, id, submissionID, answerID string) (*Gallery, error)

AddAnswer adds an answer to a form gallery. Duplicated answers are de-duplicated automatically and will not return an error.

func RemoveAnswer

func RemoveAnswer(context interface{}, db *db.DB, id, submissionID, answerID string) (*Gallery, error)

RemoveAnswer adds an answer to a form gallery. Duplicated answers are de-duplicated automatically and will not return an error.

func Retrieve

func Retrieve(context interface{}, db *db.DB, id string) (*Gallery, error)

Retrieve retrieves a form gallery from the MongoDB database collection as well as hydrating the form gallery with form submissions.

func (*Gallery) Validate

func (fg *Gallery) Validate() error

Validate checks the Gallery value for consistency.


Generated by godoc2md

# Packages

No description provided by the author

# Functions

AddAnswer adds an answer to a form gallery.
Create adds a form gallery based on the form id provided into the MongoDB database collection.
Delete removes the given Gallery with the ID provided.
List retrives the form galleries for a given form from the MongoDB database collection.
RemoveAnswer adds an answer to a form gallery.
Retrieve retrieves a form gallery from the MongoDB database collection as well as hydrating the form gallery with form submissions.
Update updates the form gallery in the MongoDB database collection.

# Constants

Collection is the mongo collection where Gallery documents are saved.

# Variables

ErrInvalidID occurs when an ID is not in a valid form.

# Structs

Answer describes an answer from a form which has been added to a Gallery.
Gallery is a Form that has been moved to a shared space.