Documentation
¶
Overview ¶
Representation of a document in couch DB
File contains all the db related functions of couch ¶
This is where all the code with respect to the documents go in.
File stores the contents in the template file so that its part of the package.
DesignDoc is needed with a name -> corresponds to the design document to query. Eash DesignDoc has a set of Views. -> Each view is a map reduce Function or raw javascript code.
Index ¶
- Variables
- type Client
- func (c *Client) DB(name string) Database
- func (c *Client) GetAuth() (string, string)
- func (c *Client) GetHost() string
- func (c *Client) GetPort() (p int)
- func (c *Client) GetPwd() string
- func (c *Client) GetTimeout() int
- func (c *Client) GetTimeoutDuration() time.Duration
- func (c *Client) GetUser() string
- func (c *Client) SetAuth(u string, p string) *Client
- func (c *Client) SetHost(h string) *Client
- func (c *Client) SetInsecure()
- func (c *Client) SetPort(p int) *Client
- func (c *Client) SetPwd(p string) *Client
- func (c *Client) SetSecure()
- func (c *Client) SetTimeout(t int) *Client
- func (c *Client) SetUser(u string) *Client
- type CouchWrapperUpdate
- type Database
- type DesignDoc
- type DocCreateResoponse
- type Document
- type Request
- func (r *Request) Delete(p string) ([]byte, error)
- func (r *Request) Get(p string, args map[string]string) ([]byte, error)
- func (r *Request) PathUrl(p string) (*url.URL, error)
- func (r *Request) Post(p string, body []byte, headers map[string]string) ([]byte, error)
- func (r *Request) Put(p string) ([]byte, error)
- type View
Constants ¶
This section is empty.
Variables ¶
var DESIGNTMPL *template.Template = template.Must(template.New("design").Parse(strings.Replace(strings.Replace(`
{
"_id": "{{.Id}}",
{{if .RevStatus}}
"_rev":"{{.Rev}}",
{{end}}
"views": {
{{range .Views}}
"{{.Name}}": {
{{if .RawJson}}
{{.RawJson}}
{{else}}
"map": " \
function({{.VariableName}}) { \
\
function get_value(doc, keys) { \
var value = {}; \
for(key in keys) { \
value[keys[key]] = doc[keys[key]];\
} \
return value; \
}\
{{if .CondStatus}}\
if({{.Condition}}) { \
emit({{.KeyName}}, get_value({{.VariableName}}, [{{.EmitStr}}]));\
} \
{{else}} \
emit({{.KeyName}}, get_value({{.VariableName}}, [{{.EmitStr}}]));\
{{end}} \
}"
{{end}}
},
{{end}}
"{{.LastView.Name}}": {
{{if .LastView.RawJson}}
{{.LastView.RawJson}}
{{else}}
"map": " \
function({{.LastView.VariableName}}) { \
\
function get_value(doc, keys) { \
var value = {}; \
for(key in keys) { \
value[keys[key]] = doc[keys[key]];\
} \
return value; \
}\
{{if .LastView.CondStatus}}\
if({{.LastView.Condition}}) { \
emit({{.LastView.KeyName}}, get_value({{.LastView.VariableName}}, [{{.LastView.EmitStr}}]));\
} \
{{else}} \
emit({{.LastView.KeyName}}, get_value({{.LastView.VariableName}}, [{{.LastView.EmitStr}}]));\
{{end}} \
}"
{{end}}
}
},
"language": "javascript"
}
`, "\\\n", "", -1), "\t", "", -1)))
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client defines the base client for the orm
func (*Client) GetTimeout ¶
GetTimeout is a thin utility for getting the timeout
func (*Client) GetTimeoutDuration ¶
GetTimeoutDuration is a thin utility for getting the timeout in duration format
func (*Client) SetInsecure ¶
func (c *Client) SetInsecure()
SetInsecure is a thin utility for setting the client to http
func (*Client) SetSecure ¶
func (c *Client) SetSecure()
SetSecure is a thin utility for setting the client to https
func (*Client) SetTimeout ¶
SetTimeout is a thin utility for setting the timeout
type CouchWrapperUpdate ¶
type DesignDoc ¶
type DesignDoc struct { Id string //The id of the document Rev string Views []*View LastView *View Db *Database RevStatus bool }
func NewDesignDoc ¶
func RetreiveDocFromDb ¶
func (*DesignDoc) CheckExists ¶
Returning index as -1 => LastView has it. Otherwise the index returned is in the view. status returns true or false indicating presence.
type DocCreateResoponse ¶
type Document ¶
Document either has an Id, Rev and the DB it connects to.
func (*Document) Create ¶
Creates a document if it does not already exist and generates an error if it already exists.
func (*Document) GetDocument ¶
Gets the document using the given id and error if it does not exist.