Adds a value or array of values to the list stored for the given key.
Optional
expire: number | InstantDetermines when the list of values stored under the given name will expire. Defaults to one week from the current [[Instant]]. If passing a number, must be in millisSinceEpoch.
Gets the list of values stored for a key. Returns an empty list if the key doesn't exist or contains an empty list.
Removes the value at the given index from the list of values stored for the name given. Returns the value removed.
Removes the value given from the list of values stored for the name given. Returns true if the value was found and removed successfully.
Clears any currently stored values and replaces them with a new list of values. The string values will be added to the list in the order defined by the index values, but the index values themselves will be discarded.
Optional
expire: number | InstantDetermines when the list of values stored under the given name will expire. Defaults to one week from the current [[Instant]]. If passing a number, must be in millisSinceEpoch.
Returns a JSON of all of the active userData keys and their cooresponding values.
Store and retrieve unstructured data in a user's account or the current session.
Overview
Historical Context: Used to maintain state between pages, e.g. style preferences or date searching.
There are many methods to store data relevant to a user.
localStorage
,sessionStorage
,cookies
,IndexedDB
,cacheStorage
, and more. bluestep.js offers its own 'session storage' in the form of UserData. UserData is insular to the user/session, i.e. data will not leak in nor out, and can only be accessed via code.Like many forms of storage (
localStorage
,sessionStorage
,cacheStorage
) and NoSQL databases, UserData is structed in key/value pairs. The underlying BlueStep database, on the other hand, is a structured database with predefined fields (the only browser analogue isIndexedDB
). Values must be strings or an array of strings. On creation, a key/value pair is given an expiration timestamp (like acookie
). Special functions are provided to allow each list of strings to be used as a stack, queue or standard list.[[B.User.userData]]
Akin to
localStorage
except saved to database; persists after session. This is not accessible to super users.[[B.sessionData]]
Akin to
sessionStorage
except saved to server's RAM; dumped after session.