Skip to content

Key Value Store

As part of a user management system it is useful to store arbitrary key/value information which can be associated with a user. This is possible with using the built-in simple key value store.

Key/values are always associated with a specific user by supplying an existing user identifier uid at creation time.

There is no pre set limit on the number of key/value pairs created per user. Nor is there any requirement on the content of the keys and values other then that the keys are strings of specific length. See the Keys/Values section of the na-user API reference

Keys must be unique per user. Two or more different users may have the same key.

If a user record is deleted, all associated key/value pairs are also automatically deleted.

The Key/Value Object

The key/value object is a small set of fields which identifies a the key and associated value.

The API presents the group object as a JSON entry with the following structure:

{
  "create_time": "2017-08-19T13:43:44Z",
  "key": "testkey100",
  "value": "TestValue100",
  "uid": "4495a67a2d964599bc827b6acbda623a",
  "update_time": "2017-08-19T13:43:44Z"
}

Below is a description of each group field and its type.

Field Name Field Type Max Length Notes
uid string 36 the uid of the user to whom the key/value pair belongs
key string 80 unique key name
value string 191 key value
update_time string 30 RFC 3339 time-date format. Example: 2017-04-05T15:18:27Z
create_time string 30 RFC 3339 time-date format. Example: 2017-04-05T15:18:27Z

Note that the timestamp fields create_time and update_time are system generated and can not be manipulated via the API.

Working with the Key Value Store

The na-user service has the following self explanatory API calls for manipulating the key/value store. See the The Keys/Values section of the na-user API Reference for full syntax and important notes about using these calls:

API Call API Endpoint
Create key POST /keys/create
Get Key POST /keys/get
Update Key Value POST /keys/update
Exists Key POST /keys/exists
Delete Key POST /keys/delete
Delete All Keys POST /keys/alldelete
List Keys Owned by User GET /keys/list/{uid}
Search Keys and Values POST /keys/search

Some of the API calls have parameters which shape the returned responses.

For example the Search Keys and Values API call can set string matching criteria, limit the set of returned values and control their sort order.