Skip to content
This repository has been archived by the owner on Mar 31, 2019. It is now read-only.

Commit

Permalink
Merge pull request #69 from Acidic9/change-reference
Browse files Browse the repository at this point in the history
Added func ref
  • Loading branch information
zabawaba99 committed Jan 15, 2017
2 parents 3ec9ea4 + 6d2aa3f commit 1607ec4
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions firebase.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,22 @@ func (fb *Firebase) Unauth() {
fb.params.Del(authParam)
}

// Ref returns a copy of an existing Firebase reference with a new path.
func (fb *Firebase) Ref(path string) (*Firebase, error) {
newFB := fb.copy()
parsedURL, err := _url.Parse(fb.url)
if err != nil {
return newFB, err
}
newFB.url = parsedURL.Scheme + "://" + parsedURL.Host + "/" + strings.Trim(path, "/")
return newFB, nil
}

// SetURL changes the url for a firebase reference.
func (fb *Firebase) SetURL(url string) {
fb.url = sanitizeURL(url)
}

// Push creates a reference to an auto-generated child location.
func (fb *Firebase) Push(v interface{}) (*Firebase, error) {
bytes, err := json.Marshal(v)
Expand Down

0 comments on commit 1607ec4

Please sign in to comment.