Skip to content

Commit 83b1466

Browse files
authored
Merge pull request #24 from stephanwilliams/import-options
Add more collection import options
2 parents b63d644 + 9dc0de0 commit 83b1466

File tree

1 file changed

+38
-3
lines changed

1 file changed

+38
-3
lines changed

requests/import.go

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,50 @@
11
package requests
22

3-
import "fmt"
4-
53
// ImportCollection imports data to a collection
64
type ImportCollection struct {
75
CollectionName string
86
Data []byte
7+
FromPrefix string
8+
ToPrefix string
9+
Overwrite bool
10+
WaitForSync bool
11+
OnDuplicate string
12+
Complete bool
13+
Details bool
914
}
1015

1116
func (c *ImportCollection) Path() string {
12-
return fmt.Sprintf("/_api/import/?type=auto&collection=%s", c.CollectionName)
17+
path := "/_api/import/?type=auto&collection=" + c.CollectionName
18+
19+
if c.FromPrefix != "" {
20+
path += "&fromPrefix=" + c.FromPrefix
21+
}
22+
23+
if c.ToPrefix != "" {
24+
path += "&toPrefix=" + c.ToPrefix
25+
}
26+
27+
if c.Overwrite {
28+
path += "&overwrite=yes"
29+
}
30+
31+
if c.WaitForSync {
32+
path += "&waitForSync=yes"
33+
}
34+
35+
if c.OnDuplicate != "" {
36+
path += "&onDuplicate=" + c.OnDuplicate
37+
}
38+
39+
if c.Complete {
40+
path += "&complete=yes"
41+
}
42+
43+
if c.Details {
44+
path += "&details=yes"
45+
}
46+
47+
return path
1348
}
1449

1550
func (c *ImportCollection) Method() string {

0 commit comments

Comments
 (0)