Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Treat KVStoreCollectionData Data Consistently #355

Closed
@malvidin

Description

@malvidin

The KVStoreCollectionData response from query_by_id is a dict. However, this requires the user to convert the dict to a string before passing it back to any function that pushes data to the collection.

Any dict returned should be able to be returned directly to other functions that modify content in the KV store.
Adding something like the following would allow backward compatibility, while permitting more flexibility to deal with the object directly without having to coerce the returned data into a string before passing it back to the KV store.

    :type data: ``string`` or ``dict``
   ... 
   if isinstance(data, dict):
       data = json.dumps(data) 
   ...

...

data = collection.data.query_by_id(id="kv_store_id")
data['key'] = 'value'
collection.data.update(id='kv_store_id', data=data) == {'_key': 'kv_store_id'}
# Instead of having the API user repeatedly call json.dumps()
# collection.data.update(id='kv_store_id', data=json.dumps(data)) == {'_key': 'kv_store_id'}

Another option would be creating a new function that wraps the insert and update functions. Either way, I expect the KVStoreCollectionData POST functions would directly accept the data it returned from its GET functions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions