Documentation ¶
Index ¶
- Constants
- Variables
- type Bucket
- func (c *Bucket) Bucket(name string) *Bucket
- func (c *Bucket) Buckets(query string, sort bool) ([]string, error)
- func (c *Bucket) Destroy(force bool) error
- func (c *Bucket) Error() error
- func (c *Bucket) Get(key string, out interface{}) error
- func (c *Bucket) Name() string
- func (c *Bucket) Objects(query string, sort bool) ([]string, error)
- func (c *Bucket) Put(key string, data interface{}, unique bool, sync bool) error
- func (c *Bucket) Query(bucketQuery string, objectQuery string, sort bool) (Result, error)
- type Result
Constants ¶
const ( ObjectPerm os.FileMode = 0640 BucketPerm os.FileMode = 0750 )
Variables ¶
var ( ErrorKeyEmpty = fault{"Empty Key.", ""} ErrorNotObjectKey = fault{"Key %s is a bucket.", ""} ErrorLocationEmpty = fault{"Location Empty.", ""} )
You should expect the following errors. the fault is an error type so you should treat them like so.
Functions ¶
This section is empty.
Types ¶
type Bucket ¶
type Bucket struct {
// contains filtered or unexported fields
}
A Buck is an structure that holds objects and bucks. It is a directory on filesystem.
func New ¶
Returns a new bucket object, it does not touch the underlying filesystem if it already exists. The codec is used for Marshling and Unmarshaling Objects. Currently there is, codec.YAML, codec.JSON, codec.GOB. To add your own. see https://godoc.org/github.com/omeid/filebase/codec.
func (*Bucket) Bucket ¶
Returns a buck with the 'name' under current bucket. It creates a new bucket if it doesn't exists.
func (*Bucket) Buckets ¶
Returns a list of buckets in the current bucket that matches the query. The syntax is same as Objects.
func (*Bucket) Destroy ¶
Deletes the bucket and returns error on failur. It will fail on non-empty buckets unless force is set to true.
func (*Bucket) Get ¶
Get returns an Object from the bucket and unmarshals it into `out` Fails on decoding failur.
func (*Bucket) Name ¶
Returns the backet name. It is same as the directory name on filesystem level.
func (*Bucket) Put ¶
Puts a new object into the bucket. An object can be any Go type, you may need to add approprate tags to your object type according to the codec used. If unique is set, it will fail if a key already exists. It will ask the underlying system to sync if sync is set to true. Object is stored under the same name in filesystem.