store

package
v0.0.0-...-dbf9b67 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

package store implements a database store for goresource.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MongoStore

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

MongoStore is a store implementation using mongodb as the database.

func (*MongoStore) Close

func (s *MongoStore) Close()

Close tears down the database connection and closes the session.

func (*MongoStore) CreateEntity

func (s *MongoStore) CreateEntity(name string, data interface{}, result interface{}) error

CreateEntity persists a new entity with the given data.

func (*MongoStore) DeleteEntity

func (s *MongoStore) DeleteEntity(name string, id string) error

DeleteEntity removes a specific entity with the given id.

func (*MongoStore) GetEntity

func (s *MongoStore) GetEntity(name string, id string, result interface{}) error

ListEntities fetches a specific entity with the given id.

func (*MongoStore) ListEntities

func (s *MongoStore) ListEntities(name string, filters url.Values, result interface{}) error

ListEntities queries and returns all entities matching the given filters.

func (*MongoStore) UpdateEntity

func (s *MongoStore) UpdateEntity(name string, id string, data interface{}, result interface{}) error

UpdateEntity updates a specific entity corresponding the given id, with the given data.

type Store

type Store interface {
	GetEntity(name string, id string, result interface{}) error
	CreateEntity(name string, data interface{}, result interface{}) error
	ListEntities(name string, filters url.Values, result interface{}) error
	UpdateEntity(name string, id string, data interface{}, result interface{}) error
	DeleteEntity(name string, id string) error
	Close()
}

Store iterface is implemented by database stores.

func NewMongoStore

func NewMongoStore(addr string, database string, timeout time.Duration) (Store, error)

NewMongoStore returns an initialized store or any initialization errors.

Jump to

Keyboard shortcuts

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