Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
IntergrationProject
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mateusz Tomasz Kaczmarek
IntergrationProject
Commits
d4347f0c
Commit
d4347f0c
authored
8 months ago
by
Snorre Hareide Hansen
Browse files
Options
Downloads
Patches
Plain Diff
reverted all changes from SplitPath
parent
822920d9
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Project/Firebase/firestore.go
+11
-11
11 additions, 11 deletions
Project/Firebase/firestore.go
Project/Firebase/functions.go
+6
-9
6 additions, 9 deletions
Project/Firebase/functions.go
with
17 additions
and
20 deletions
Project/Firebase/firestore.go
+
11
−
11
View file @
d4347f0c
...
...
@@ -10,7 +10,7 @@ import (
// Get a document
func
(
fs
Firestore
)
GetDoc
(
path
string
)
(
Document
,
error
)
{
collection
,
id
,
subCollection
,
subId
,
_
,
err
:=
SplitPath
(
path
)
collection
,
id
,
subCollection
,
subId
,
err
:=
SplitPath
(
path
)
if
err
!=
nil
{
return
Document
{},
err
}
...
...
@@ -35,7 +35,7 @@ func (fs Firestore) GetDoc(path string) (Document, error) {
// Delete a document
func
(
fs
Firestore
)
DeleteDoc
(
path
string
)
error
{
collection
,
id
,
subCollection
,
subId
,
_
,
err
:=
SplitPath
(
path
)
collection
,
id
,
subCollection
,
subId
,
err
:=
SplitPath
(
path
)
if
err
!=
nil
{
return
err
}
...
...
@@ -55,7 +55,7 @@ func (fs Firestore) DeleteDoc(path string) error {
// Update a document
func
(
fs
Firestore
)
UpdateDoc
(
path
string
,
newValues
map
[
string
]
interface
{})
error
{
collection
,
id
,
subCollection
,
subId
,
_
,
err
:=
SplitPath
(
path
)
collection
,
id
,
subCollection
,
subId
,
err
:=
SplitPath
(
path
)
if
err
!=
nil
{
return
err
}
...
...
@@ -89,7 +89,7 @@ func (fs Firestore) GetDocsWhere(path string, conditionValues map[string]interfa
return []Document{}, errors.New("no conditions")
}*/
collection
,
id
,
subCollection
,
_
,
_
,
err
:=
SplitPath
(
path
)
collection
,
id
,
subCollection
,
_
,
err
:=
SplitPath
(
path
)
if
err
!=
nil
{
return
[]
Document
{},
err
}
...
...
@@ -142,7 +142,7 @@ func (fs Firestore) DeleteDocsWhere(path string, conditionValues map[string]inte
return
errors
.
New
(
"no conditions"
)
}
collection
,
id
,
subCollection
,
_
,
_
,
err
:=
SplitPath
(
path
)
collection
,
id
,
subCollection
,
_
,
err
:=
SplitPath
(
path
)
if
err
!=
nil
{
return
err
}
...
...
@@ -195,7 +195,7 @@ func (fs Firestore) UpdateDocsWhere(path string, newValues map[string]interface{
return
errors
.
New
(
"no conditions"
)
}
collection
,
id
,
subCollection
,
_
,
_
,
err
:=
SplitPath
(
path
)
collection
,
id
,
subCollection
,
_
,
err
:=
SplitPath
(
path
)
if
err
!=
nil
{
return
err
}
...
...
@@ -246,7 +246,7 @@ func (fs Firestore) UpdateDocsWhere(path string, newValues map[string]interface{
// Post document
func
(
fs
Firestore
)
PostDoc
(
path
string
,
values
map
[
string
]
interface
{})
error
{
collection
,
id
,
subCollection
,
_
,
_
,
err
:=
SplitPath
(
path
)
collection
,
id
,
subCollection
,
_
,
err
:=
SplitPath
(
path
)
if
err
!=
nil
{
return
err
}
...
...
@@ -268,7 +268,7 @@ func (fs Firestore) PostDoc(path string, values map[string]interface{}) error {
// Post a document with specified id
func
(
fs
Firestore
)
PostDocId
(
path
string
,
id
string
,
values
map
[
string
]
interface
{})
error
{
collection
,
docId
,
subCollection
,
_
,
_
,
err
:=
SplitPath
(
path
)
collection
,
docId
,
subCollection
,
_
,
err
:=
SplitPath
(
path
)
if
err
!=
nil
{
return
err
}
...
...
@@ -290,7 +290,7 @@ func (fs Firestore) PostDocId(path string, id string, values map[string]interfac
// Increment one or more numeric fields of a document
func
(
fs
Firestore
)
IncrementDocField
(
path
string
,
fields
map
[
string
]
interface
{})
error
{
collection
,
id
,
subCollection
,
subId
,
_
,
err
:=
SplitPath
(
path
)
collection
,
id
,
subCollection
,
subId
,
err
:=
SplitPath
(
path
)
if
err
!=
nil
{
return
err
}
...
...
@@ -334,7 +334,7 @@ func (fs Firestore) GetPaginatedDocs(path string, pageNum int, pageSize int) ([]
return
nil
,
errors
.
New
(
"invalid pagination values"
)
}
collection
,
_
,
_
,
_
,
_
,
err
:=
SplitPath
(
path
)
collection
,
_
,
_
,
_
,
err
:=
SplitPath
(
path
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -373,7 +373,7 @@ func (fs Firestore) SearchDocs(path string, searchTerm string, pageNum int, page
return
nil
,
errors
.
New
(
"invalid pagination values"
)
}
collection
,
_
,
_
,
_
,
_
,
err
:=
SplitPath
(
path
)
collection
,
_
,
_
,
_
,
err
:=
SplitPath
(
path
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
This diff is collapsed.
Click to expand it.
Project/Firebase/functions.go
+
6
−
9
View file @
d4347f0c
...
...
@@ -6,30 +6,27 @@ import (
)
// Splits a path to a document, with a maximum of one subcollection
func
SplitPath
(
path
string
)
(
string
,
string
,
string
,
string
,
string
,
error
)
{
func
SplitPath
(
path
string
)
(
string
,
string
,
string
,
string
,
error
)
{
words
:=
strings
.
Split
(
path
,
"/"
)
// Invalid path
if
len
(
words
)
<
1
||
len
(
words
)
>
5
{
return
""
,
""
,
""
,
""
,
""
,
errors
.
New
(
"invalid path"
)
return
""
,
""
,
""
,
""
,
errors
.
New
(
"invalid path"
)
}
if
len
(
words
)
==
1
{
return
words
[
0
],
""
,
""
,
""
,
""
,
nil
return
words
[
0
],
""
,
""
,
""
,
nil
}
if
len
(
words
)
==
2
{
return
words
[
0
],
words
[
1
],
""
,
""
,
""
,
nil
return
words
[
0
],
words
[
1
],
""
,
""
,
nil
}
if
len
(
words
)
==
3
{
return
words
[
0
],
words
[
1
],
words
[
2
],
""
,
""
,
nil
}
if
len
(
words
)
==
4
{
return
words
[
0
],
words
[
1
],
words
[
2
],
words
[
3
],
""
,
nil
return
words
[
0
],
words
[
1
],
words
[
2
],
""
,
nil
}
return
words
[
0
],
words
[
1
],
words
[
2
],
words
[
3
],
words
[
4
],
nil
return
words
[
0
],
words
[
1
],
words
[
2
],
words
[
3
],
nil
}
// Delete a user's review for a game. Returns whether or not the review was deleted.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment