Documentation ¶
Index ¶
- func CreateOrUpdate(ctx context.Context, domain string, kv *model.KVDoc, project string) (*model.KVDoc, error)
- func Delete(kvID string, labelID string, domain string, project string) error
- func DeleteKV(ctx context.Context, hexID primitive.ObjectID, project string) error
- func FindKV(ctx context.Context, domain string, project string, options ...FindOption) ([]*model.KVResponse, error)
- func FindKVByLabelID(ctx context.Context, domain, labelID, key string, project string) ([]*model.KVDoc, error)
- func KVExist(ctx context.Context, domain, key string, project string, options ...FindOption) (primitive.ObjectID, error)
- type FindOption
- type FindOptions
- type MongodbService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateOrUpdate ¶
func CreateOrUpdate(ctx context.Context, domain string, kv *model.KVDoc, project string) (*model.KVDoc, error)
CreateOrUpdate will create or update a key value record it first check label exists or not, and create labels if labels is first posted. if label exists, then get its latest revision, and update current revision, save the current label and its all key values to history collection then check key exists or not, then create or update it
func Delete ¶
Delete delete kv,If the labelID is "", query the collection kv to get it domain=tenant 1.delete kv;2.add history
func FindKV ¶
func FindKV(ctx context.Context, domain string, project string, options ...FindOption) ([]*model.KVResponse, error)
FindKV get kvs by key, labels because labels has a a lot of combination, you can use WithDepth(0) to return only one kv which's labels exactly match the criteria
Types ¶
type FindOption ¶
type FindOption func(*FindOptions)
FindOption is functional option to find key value
func WithDepth ¶
func WithDepth(d int) FindOption
WithDepth if you use greedy match this can specify the match depth
func WithExactLabels ¶
func WithExactLabels() FindOption
WithExactLabels tell model service to return only one kv matches the labels
func WithOutLabelField ¶
func WithOutLabelField() FindOption
WithOutLabelField will clear all labels attributes in kv doc
func WithTimeout ¶
func WithTimeout(d time.Duration) FindOption
WithTimeout will return err if execution take too long
type FindOptions ¶
type FindOptions struct { ExactLabels bool Depth int Key string Labels map[string]string LabelID string ClearLabel bool Timeout time.Duration }
FindOptions is option to find key value
type MongodbService ¶
type MongodbService struct {
// contains filtered or unexported fields
}
MongodbService operate data in mongodb