Sift Storage
get (params)
Retrieves key/value objects from a given bucket.
Params:
bucket
: the name of the bucket to retrieve info fromkeys
: array of keys to retrieve
params = {
"bucket": "name",
"keys": ["key1", "key2"]
}
Returns:
- Promise: the promise resolves to an array of JSON objects or rejects with error information.
response = {[
{"key": "key1", "value": "v1"},
{"key": "key2", "value": undefined}
]}
getIndexKeys (params)
List keys for a given index range.
Params:
bucket
: the name of the bucket to retrieve info fromindex
: the name of the indexrange
: Mongo-inspired query object. Supported queries are:gt
(greater than),lt
(less than),gte
(greater than or equal),lte
(less than or equal),eq
(equal).
params = {
"bucket": "name",
"index": "indexname",
"range": {
"gt": 5
"lte": 10
}
}
Returns:
- Promise: the promise resolves to an array of JSON objects or rejects with error information.
response = [
{ "key": "msg1", "index": 6 },
{ "key": "msg2", "index": 7 }
]
Range limitations
Values used inside range queries must be numeric.
getIndex (params)
Same as getIndexKeys(params) but also returns the value for each key.
response = [
{
"key": "msg1",
"index": 6,
"value": "hello,"
},
{
"key": "msg2",
"index": 7,
"value: "is it me you are looking for?"
}
]
getWithIndex (params)
Retrieves key/value objects from a key list that match a given index.
Params:
bucket
: the name of the bucket to retrieve info fromindex
: the name of the indexkeys
: array of keys to searchrange
: This API only supportseq
(equal) range.
params = {
"bucket": "name",
"index": "indexname",
"keys": ["k1", "k2", "k3"],
"range": {
"eq": 10
}
}
Returns:
- Promise: the promise resolves to an array of JSON objects or rejects with error information.
// Example response
var response = [
{ "key": "k1", "value": "value" },
{ "key": "k2", "value": undefined },
{ "key": "k3", "value": "value" }
];
getAllKeys (params)
Retrieves all keys for a given bucket.
Params:
bucket
: the name of the bucket to retrieve info from
params = { "bucket": "name" }
Returns:
- Promise: the promise resolves to an array of JSON objects or rejects with error information.
response = [ "msg1", "msg2", "msg3" ]
getAll (params)
Retrieves a list of all key/value objects for a given bucket.
Params:
bucket
: the name of the bucket to retrieve info from
params = { "bucket": "name" }
Returns:
- Promise: the promise resolves to an array of JSON objects or rejects with error information.
// Example response
var response = [
{ "key": "msg1", "value": "value1" },
{ "key": "msg2", "value": "value2" },
{ "key": "msg3", "value": "value3" }
];
getUser (params)
Same functionality as get(params) but for the user bucket. Only difference the bucket
field can be omitted from the params
argument as it is known. If defined, bucket
will be ignored and the _user
bucket will be queried instead.
putUser (params)
Write or update any number of keys inside the user bucket.
Params:
kvs
: an array of key/value objects to write.
params = {
"kvs":[
{ "key": "key1", "value": "value1" },
{ "key": "key2", "value": "value2" },
{ "key": "key3", "value": "value3" }
]
}
Returns:
- Promise: the promise resolves or rejects with error information.
delUser (params)
Delete any number of keys inside the user bucket.
Params:
keys
: array of keys
params = { "keys": ["key1", "key2"] }
Returns:
- Promise: the promise resolves or rejects with error information.
Updated less than a minute ago