Commit ca13e9b2 authored by Łukasz Magiera's avatar Łukasz Magiera

coreapi: Pin option for Object.Put

License: MIT
Signed-off-by: default avatarŁukasz Magiera <magik6k@gmail.com>
parent ebc2b357
...@@ -7,6 +7,7 @@ type ObjectNewSettings struct { ...@@ -7,6 +7,7 @@ type ObjectNewSettings struct {
type ObjectPutSettings struct { type ObjectPutSettings struct {
InputEnc string InputEnc string
DataType string DataType string
Pin bool
} }
type ObjectAddLinkSettings struct { type ObjectAddLinkSettings struct {
...@@ -35,6 +36,7 @@ func ObjectPutOptions(opts ...ObjectPutOption) (*ObjectPutSettings, error) { ...@@ -35,6 +36,7 @@ func ObjectPutOptions(opts ...ObjectPutOption) (*ObjectPutSettings, error) {
options := &ObjectPutSettings{ options := &ObjectPutSettings{
InputEnc: "json", InputEnc: "json",
DataType: "text", DataType: "text",
Pin: false,
} }
for _, opt := range opts { for _, opt := range opts {
...@@ -103,6 +105,15 @@ func (objectOpts) DataType(t string) ObjectPutOption { ...@@ -103,6 +105,15 @@ func (objectOpts) DataType(t string) ObjectPutOption {
} }
} }
// WithPin is an option for Object.Put which specifies whether to pin the added
// objects, default is false
func (objectOpts) WithPin(pin bool) ObjectPutOption {
return func(settings *ObjectPutSettings) error {
settings.Pin = pin
return nil
}
}
// Create is an option for Object.AddLink which specifies whether create required // Create is an option for Object.AddLink which specifies whether create required
// directories for the child // directories for the child
func (objectOpts) Create(create bool) ObjectAddLinkOption { func (objectOpts) Create(create bool) ObjectAddLinkOption {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment