backendless 6.5.0 → 6.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/backendless.d.ts +51 -47
- package/dist/backendless.js +174 -54
- package/dist/backendless.js.map +1 -1
- package/dist/backendless.min.js +2 -2
- package/es/hive/stores/key-value.js +6 -0
- package/es/hive/stores/list.js +41 -17
- package/es/hive/stores/map.js +6 -4
- package/es/hive/stores/set.js +65 -21
- package/es/hive/stores/sorted-set.js +25 -11
- package/es/hive/utils.js +19 -0
- package/lib/hive/stores/key-value.js +6 -0
- package/lib/hive/stores/list.js +41 -17
- package/lib/hive/stores/map.js +6 -4
- package/lib/hive/stores/set.js +65 -21
- package/lib/hive/stores/sorted-set.js +25 -11
- package/lib/hive/utils.js +19 -0
- package/package.json +1 -1
- package/src/hive/stores/key-value.js +5 -0
- package/src/hive/stores/list.js +39 -15
- package/src/hive/stores/map.js +5 -4
- package/src/hive/stores/set.js +62 -18
- package/src/hive/stores/sorted-set.js +24 -12
- package/src/hive/utils.js +13 -0
package/lib/hive/stores/set.js
CHANGED
|
@@ -25,7 +25,7 @@ var _baseStore = require("./base-store");
|
|
|
25
25
|
|
|
26
26
|
var _constants = require("../constants");
|
|
27
27
|
|
|
28
|
-
var _utils =
|
|
28
|
+
var _utils = require("../utils");
|
|
29
29
|
|
|
30
30
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
31
31
|
|
|
@@ -77,55 +77,99 @@ var SetStore = /*#__PURE__*/function (_HiveStore) {
|
|
|
77
77
|
});
|
|
78
78
|
}
|
|
79
79
|
}, {
|
|
80
|
-
key: "
|
|
81
|
-
value: function
|
|
82
|
-
if (!
|
|
83
|
-
throw new Error('Value
|
|
80
|
+
key: "setValue",
|
|
81
|
+
value: function setValue(value) {
|
|
82
|
+
if (!(0, _utils.isHiveValueValid)(value)) {
|
|
83
|
+
throw new Error('Value must be provided and must be one of types: string, number, boolean, object, array.');
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
return this.app.request.put({
|
|
87
87
|
url: this.getBaseURL(),
|
|
88
|
-
data:
|
|
88
|
+
data: [value]
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
91
|
}, {
|
|
92
|
-
key: "
|
|
93
|
-
value: function
|
|
94
|
-
if (!values || !(
|
|
95
|
-
throw new Error('Value
|
|
92
|
+
key: "setValues",
|
|
93
|
+
value: function setValues(values) {
|
|
94
|
+
if (!values || !Array.isArray(values) || !values.length || !(0, _utils.isHiveValueValid)(values)) {
|
|
95
|
+
throw new Error('Value must be provided and must be a list of valid JSON items.');
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return this.app.request.put({
|
|
99
|
+
url: this.getBaseURL(),
|
|
100
|
+
data: values
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}, {
|
|
104
|
+
key: "addValue",
|
|
105
|
+
value: function addValue(value) {
|
|
106
|
+
if (!(0, _utils.isHiveValueValid)(value)) {
|
|
107
|
+
throw new Error('Value must be provided and must be one of types: string, number, boolean, object, array.');
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return this.app.request.put({
|
|
111
|
+
url: "".concat(this.getBaseURL(), "/add"),
|
|
112
|
+
data: [value]
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}, {
|
|
116
|
+
key: "addValues",
|
|
117
|
+
value: function addValues(values) {
|
|
118
|
+
if (!values || !Array.isArray(values) || !values.length || !(0, _utils.isHiveValueValid)(values)) {
|
|
119
|
+
throw new Error('Value must be provided and must be a list of valid JSON items.');
|
|
96
120
|
}
|
|
97
121
|
|
|
98
122
|
return this.app.request.put({
|
|
99
123
|
url: "".concat(this.getBaseURL(), "/add"),
|
|
100
|
-
data:
|
|
124
|
+
data: values
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}, {
|
|
128
|
+
key: "deleteValue",
|
|
129
|
+
value: function deleteValue(value) {
|
|
130
|
+
if (!(0, _utils.isHiveValueValid)(value)) {
|
|
131
|
+
throw new Error('Value must be provided and must be one of types: string, number, boolean, object, array.');
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return this.app.request["delete"]({
|
|
135
|
+
url: "".concat(this.getBaseURL(), "/values"),
|
|
136
|
+
data: [value]
|
|
101
137
|
});
|
|
102
138
|
}
|
|
103
139
|
}, {
|
|
104
140
|
key: "deleteValues",
|
|
105
141
|
value: function deleteValues(values) {
|
|
106
|
-
if (!values || !(
|
|
107
|
-
throw new Error('Value
|
|
142
|
+
if (!values || !Array.isArray(values) || !values.length || !(0, _utils.isHiveValueValid)(values)) {
|
|
143
|
+
throw new Error('Value must be provided and must be a list of valid JSON items.');
|
|
108
144
|
}
|
|
109
145
|
|
|
110
146
|
return this.app.request["delete"]({
|
|
111
147
|
url: "".concat(this.getBaseURL(), "/values"),
|
|
112
|
-
data:
|
|
148
|
+
data: values
|
|
113
149
|
});
|
|
114
150
|
}
|
|
115
151
|
}, {
|
|
116
|
-
key: "
|
|
117
|
-
value: function
|
|
118
|
-
if (
|
|
119
|
-
|
|
152
|
+
key: "isValueMember",
|
|
153
|
+
value: function isValueMember(value) {
|
|
154
|
+
if (!(0, _utils.isHiveValueValid)(value)) {
|
|
155
|
+
throw new Error('Value must be provided and must be one of types: string, number, boolean, object, array.');
|
|
120
156
|
}
|
|
121
157
|
|
|
122
|
-
|
|
123
|
-
|
|
158
|
+
return this.app.request.post({
|
|
159
|
+
url: "".concat(this.getBaseURL(), "/contains"),
|
|
160
|
+
data: [value]
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}, {
|
|
164
|
+
key: "isValuesMembers",
|
|
165
|
+
value: function isValuesMembers(values) {
|
|
166
|
+
if (!values || !Array.isArray(values) || !values.length || !(0, _utils.isHiveValueValid)(values)) {
|
|
167
|
+
throw new Error('Value must be provided and must be a list of valid JSON items.');
|
|
124
168
|
}
|
|
125
169
|
|
|
126
170
|
return this.app.request.post({
|
|
127
171
|
url: "".concat(this.getBaseURL(), "/contains"),
|
|
128
|
-
data:
|
|
172
|
+
data: values
|
|
129
173
|
});
|
|
130
174
|
}
|
|
131
175
|
}, {
|
|
@@ -29,6 +29,8 @@ var _utils = _interopRequireDefault(require("../../utils"));
|
|
|
29
29
|
|
|
30
30
|
var _set = require("./set");
|
|
31
31
|
|
|
32
|
+
var _utils2 = require("../utils");
|
|
33
|
+
|
|
32
34
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
33
35
|
|
|
34
36
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
@@ -123,8 +125,8 @@ var SortedSetStore = /*#__PURE__*/function (_HiveStore) {
|
|
|
123
125
|
}, {
|
|
124
126
|
key: "incrementScore",
|
|
125
127
|
value: function incrementScore(value, scoreValue) {
|
|
126
|
-
if (!
|
|
127
|
-
throw new Error('Value must be provided and must be
|
|
128
|
+
if (!(0, _utils2.isHiveValueValid)(value)) {
|
|
129
|
+
throw new Error('Value must be provided and must be one of types: string, number, boolean, object, array.');
|
|
128
130
|
}
|
|
129
131
|
|
|
130
132
|
if (isNaN(scoreValue) || typeof scoreValue !== 'number') {
|
|
@@ -142,8 +144,8 @@ var SortedSetStore = /*#__PURE__*/function (_HiveStore) {
|
|
|
142
144
|
}, {
|
|
143
145
|
key: "decrementScore",
|
|
144
146
|
value: function decrementScore(value, scoreValue) {
|
|
145
|
-
if (!
|
|
146
|
-
throw new Error('Value must be provided and must be
|
|
147
|
+
if (!(0, _utils2.isHiveValueValid)(value)) {
|
|
148
|
+
throw new Error('Value must be provided and must be one of types: string, number, boolean, object, array.');
|
|
147
149
|
}
|
|
148
150
|
|
|
149
151
|
if (isNaN(scoreValue) || typeof scoreValue !== 'number') {
|
|
@@ -214,8 +216,8 @@ var SortedSetStore = /*#__PURE__*/function (_HiveStore) {
|
|
|
214
216
|
}, {
|
|
215
217
|
key: "getScore",
|
|
216
218
|
value: function getScore(value) {
|
|
217
|
-
if (!
|
|
218
|
-
throw new Error('Value must be provided and must be
|
|
219
|
+
if (!(0, _utils2.isHiveValueValid)(value)) {
|
|
220
|
+
throw new Error('Value must be provided and must be one of types: string, number, boolean, object, array.');
|
|
219
221
|
}
|
|
220
222
|
|
|
221
223
|
return this.app.request.post({
|
|
@@ -228,8 +230,8 @@ var SortedSetStore = /*#__PURE__*/function (_HiveStore) {
|
|
|
228
230
|
}, {
|
|
229
231
|
key: "getRank",
|
|
230
232
|
value: function getRank(value, reverse) {
|
|
231
|
-
if (!
|
|
232
|
-
throw new Error('Value must be provided and must be
|
|
233
|
+
if (!(0, _utils2.isHiveValueValid)(value)) {
|
|
234
|
+
throw new Error('Value must be provided and must be one of types: string, number, boolean, object, array.');
|
|
233
235
|
}
|
|
234
236
|
|
|
235
237
|
if (reverse !== undefined && typeof reverse !== 'boolean') {
|
|
@@ -335,16 +337,28 @@ var SortedSetStore = /*#__PURE__*/function (_HiveStore) {
|
|
|
335
337
|
query: _objectSpread({}, options)
|
|
336
338
|
});
|
|
337
339
|
}
|
|
340
|
+
}, {
|
|
341
|
+
key: "deleteValue",
|
|
342
|
+
value: function deleteValue(value) {
|
|
343
|
+
if (!(0, _utils2.isHiveValueValid)(value)) {
|
|
344
|
+
throw new Error('Value must be provided and must be one of types: string, number, boolean, object, array.');
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
return this.app.request["delete"]({
|
|
348
|
+
url: "".concat(this.getBaseURL(), "/values"),
|
|
349
|
+
data: [value]
|
|
350
|
+
});
|
|
351
|
+
}
|
|
338
352
|
}, {
|
|
339
353
|
key: "deleteValues",
|
|
340
354
|
value: function deleteValues(values) {
|
|
341
|
-
if (!values || !(
|
|
342
|
-
throw new Error('Value
|
|
355
|
+
if (!values || !Array.isArray(values) || !values.length || !(0, _utils2.isHiveValueValid)(values)) {
|
|
356
|
+
throw new Error('Value must be provided and must be a list of JSON items.');
|
|
343
357
|
}
|
|
344
358
|
|
|
345
359
|
return this.app.request["delete"]({
|
|
346
360
|
url: "".concat(this.getBaseURL(), "/values"),
|
|
347
|
-
data:
|
|
361
|
+
data: values
|
|
348
362
|
});
|
|
349
363
|
}
|
|
350
364
|
}, {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isHiveValueValid = isHiveValueValid;
|
|
7
|
+
|
|
8
|
+
function isHiveValueValid(value) {
|
|
9
|
+
if (value == null) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
try {
|
|
14
|
+
var json = JSON.stringify(value);
|
|
15
|
+
return !!json;
|
|
16
|
+
} catch (_unused) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { HiveTypes } from '../constants'
|
|
2
2
|
import { HiveStore } from './base-store'
|
|
3
3
|
import Utils from '../../utils'
|
|
4
|
+
import { isHiveValueValid } from '../utils'
|
|
4
5
|
|
|
5
6
|
export class KeyValueStore extends HiveStore {
|
|
6
7
|
|
|
@@ -57,6 +58,10 @@ export class KeyValueStore extends HiveStore {
|
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
60
|
|
|
61
|
+
if (!isHiveValueValid(value)) {
|
|
62
|
+
throw new Error('Value must be provided and must be one of types: string, number, boolean, object, array.')
|
|
63
|
+
}
|
|
64
|
+
|
|
60
65
|
return this.app.request
|
|
61
66
|
.put({
|
|
62
67
|
url : `${this.app.urls.hiveStore(this.hiveName, this.TYPE)}/${key}`,
|
package/src/hive/stores/list.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HiveTypes } from '../constants'
|
|
2
2
|
import { HiveStore } from './base-store'
|
|
3
|
-
import
|
|
3
|
+
import { isHiveValueValid } from '../utils'
|
|
4
4
|
|
|
5
5
|
export class ListStore extends HiveStore {
|
|
6
6
|
|
|
@@ -78,12 +78,12 @@ export class ListStore extends HiveStore {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
insert(valueToInsert, anchorValue, before) {
|
|
81
|
-
if (!valueToInsert
|
|
82
|
-
throw new Error('ValueToInsert must be provided and must be
|
|
81
|
+
if (!isHiveValueValid(valueToInsert)) {
|
|
82
|
+
throw new Error('ValueToInsert must be provided and must be on of types: string, number, boolean, object, array.')
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
if (!anchorValue
|
|
86
|
-
throw new Error('AnchorValue must be provided and must be
|
|
85
|
+
if (!isHiveValueValid(anchorValue)) {
|
|
86
|
+
throw new Error('AnchorValue must be provided and must be one of types: string, number, boolean, object, array.')
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
return this.app.request
|
|
@@ -97,8 +97,8 @@ export class ListStore extends HiveStore {
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
deleteValue(value, count) {
|
|
100
|
-
if (!value
|
|
101
|
-
throw new Error('Value must be provided and must be
|
|
100
|
+
if (!isHiveValueValid(value)) {
|
|
101
|
+
throw new Error('Value must be provided and must be one of types: string, number, boolean, object, array.')
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
if (count !== undefined && (isNaN(count) || typeof count !== 'number')) {
|
|
@@ -115,27 +115,51 @@ export class ListStore extends HiveStore {
|
|
|
115
115
|
})
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
|
|
119
|
-
if (!
|
|
120
|
-
throw new Error('Value
|
|
118
|
+
addFirstValue(value) {
|
|
119
|
+
if (!isHiveValueValid(value)) {
|
|
120
|
+
throw new Error('Value must be provided and must be one of types: string, number, boolean, object, array.')
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
return this.app.request
|
|
124
124
|
.put({
|
|
125
125
|
url : `${this.getBaseURL()}/add-first`,
|
|
126
|
-
data:
|
|
126
|
+
data: [value]
|
|
127
127
|
})
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
|
|
131
|
-
if (!
|
|
132
|
-
throw new Error('Value
|
|
130
|
+
addFirstValues(values) {
|
|
131
|
+
if (!values || !Array.isArray(values) || !values.length || !isHiveValueValid(values)) {
|
|
132
|
+
throw new Error('Value must be provided and must be a list of valid JSON items.')
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return this.app.request
|
|
136
|
+
.put({
|
|
137
|
+
url : `${this.getBaseURL()}/add-first`,
|
|
138
|
+
data: values
|
|
139
|
+
})
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
addLastValue(value) {
|
|
143
|
+
if (!isHiveValueValid(value)) {
|
|
144
|
+
throw new Error('Value must be provided and must be one of types: string, number, boolean, object, array.')
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return this.app.request
|
|
148
|
+
.put({
|
|
149
|
+
url : `${this.getBaseURL()}/add-last`,
|
|
150
|
+
data: [value]
|
|
151
|
+
})
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
addLastValues(values) {
|
|
155
|
+
if (!values || !Array.isArray(values) || !values.length || !isHiveValueValid(values)) {
|
|
156
|
+
throw new Error('Value must be provided and must be a list of valid JSON items.')
|
|
133
157
|
}
|
|
134
158
|
|
|
135
159
|
return this.app.request
|
|
136
160
|
.put({
|
|
137
161
|
url : `${this.getBaseURL()}/add-last`,
|
|
138
|
-
data:
|
|
162
|
+
data: values
|
|
139
163
|
})
|
|
140
164
|
}
|
|
141
165
|
|
package/src/hive/stores/map.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { HiveTypes } from '../constants'
|
|
2
2
|
import { HiveStore } from './base-store'
|
|
3
3
|
import Utils from '../../utils'
|
|
4
|
+
import { isHiveValueValid } from '../utils'
|
|
4
5
|
|
|
5
6
|
export class MapStore extends HiveStore {
|
|
6
7
|
|
|
@@ -82,8 +83,8 @@ export class MapStore extends HiveStore {
|
|
|
82
83
|
throw new Error('Key must be a string.')
|
|
83
84
|
}
|
|
84
85
|
|
|
85
|
-
if (!value
|
|
86
|
-
throw new Error('Value must be provided and must be
|
|
86
|
+
if (!isHiveValueValid(value)) {
|
|
87
|
+
throw new Error('Value must be provided and must be one of types: string, number, boolean, object, array.')
|
|
87
88
|
}
|
|
88
89
|
|
|
89
90
|
return this.app.request
|
|
@@ -100,8 +101,8 @@ export class MapStore extends HiveStore {
|
|
|
100
101
|
throw new Error('Key must be provided and must be a string.')
|
|
101
102
|
}
|
|
102
103
|
|
|
103
|
-
if (!value
|
|
104
|
-
throw new Error('Value must be provided and must be
|
|
104
|
+
if (!isHiveValueValid(value)) {
|
|
105
|
+
throw new Error('Value must be provided and must be one of types: string, number, boolean, object, array.')
|
|
105
106
|
}
|
|
106
107
|
|
|
107
108
|
if (overwrite !== undefined && typeof overwrite !== 'boolean') {
|
package/src/hive/stores/set.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HiveStore } from './base-store'
|
|
2
2
|
import { HiveTypes } from '../constants'
|
|
3
|
-
import
|
|
3
|
+
import { isHiveValueValid } from '../utils'
|
|
4
4
|
|
|
5
5
|
export class SetStore extends HiveStore {
|
|
6
6
|
|
|
@@ -75,55 +75,99 @@ export class SetStore extends HiveStore {
|
|
|
75
75
|
})
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
if (!
|
|
80
|
-
throw new Error('Value
|
|
78
|
+
setValue(value) {
|
|
79
|
+
if (!isHiveValueValid(value)) {
|
|
80
|
+
throw new Error('Value must be provided and must be one of types: string, number, boolean, object, array.')
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
return this.app.request
|
|
84
84
|
.put({
|
|
85
85
|
url : this.getBaseURL(),
|
|
86
|
-
data:
|
|
86
|
+
data: [value]
|
|
87
87
|
})
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
|
|
91
|
-
if (!values || !(
|
|
92
|
-
throw new Error('Value
|
|
90
|
+
setValues(values) {
|
|
91
|
+
if (!values || !Array.isArray(values) || !values.length || !isHiveValueValid(values)) {
|
|
92
|
+
throw new Error('Value must be provided and must be a list of valid JSON items.')
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return this.app.request
|
|
96
|
+
.put({
|
|
97
|
+
url : this.getBaseURL(),
|
|
98
|
+
data: values
|
|
99
|
+
})
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
addValue(value) {
|
|
103
|
+
if (!isHiveValueValid(value)) {
|
|
104
|
+
throw new Error('Value must be provided and must be one of types: string, number, boolean, object, array.')
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return this.app.request
|
|
108
|
+
.put({
|
|
109
|
+
url : `${this.getBaseURL()}/add`,
|
|
110
|
+
data: [value]
|
|
111
|
+
})
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
addValues(values) {
|
|
115
|
+
if (!values || !Array.isArray(values) || !values.length || !isHiveValueValid(values)) {
|
|
116
|
+
throw new Error('Value must be provided and must be a list of valid JSON items.')
|
|
93
117
|
}
|
|
94
118
|
|
|
95
119
|
return this.app.request
|
|
96
120
|
.put({
|
|
97
121
|
url : `${this.getBaseURL()}/add`,
|
|
98
|
-
data:
|
|
122
|
+
data: values
|
|
123
|
+
})
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
deleteValue(value) {
|
|
127
|
+
if (!isHiveValueValid(value)) {
|
|
128
|
+
throw new Error('Value must be provided and must be one of types: string, number, boolean, object, array.')
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return this.app.request
|
|
132
|
+
.delete({
|
|
133
|
+
url : `${this.getBaseURL()}/values`,
|
|
134
|
+
data: [value]
|
|
99
135
|
})
|
|
100
136
|
}
|
|
101
137
|
|
|
102
138
|
deleteValues(values) {
|
|
103
|
-
if (!values || !(
|
|
104
|
-
throw new Error('Value
|
|
139
|
+
if (!values || !Array.isArray(values) || !values.length || !isHiveValueValid(values)) {
|
|
140
|
+
throw new Error('Value must be provided and must be a list of valid JSON items.')
|
|
105
141
|
}
|
|
106
142
|
|
|
107
143
|
return this.app.request
|
|
108
144
|
.delete({
|
|
109
145
|
url : `${this.getBaseURL()}/values`,
|
|
110
|
-
data:
|
|
146
|
+
data: values
|
|
111
147
|
})
|
|
112
148
|
}
|
|
113
149
|
|
|
114
|
-
|
|
115
|
-
if (
|
|
116
|
-
|
|
150
|
+
isValueMember(value) {
|
|
151
|
+
if (!isHiveValueValid(value)) {
|
|
152
|
+
throw new Error('Value must be provided and must be one of types: string, number, boolean, object, array.')
|
|
117
153
|
}
|
|
118
154
|
|
|
119
|
-
|
|
120
|
-
|
|
155
|
+
return this.app.request
|
|
156
|
+
.post({
|
|
157
|
+
url : `${this.getBaseURL()}/contains`,
|
|
158
|
+
data: [value]
|
|
159
|
+
})
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
isValuesMembers(values) {
|
|
163
|
+
if (!values || !Array.isArray(values) || !values.length || !isHiveValueValid(values)) {
|
|
164
|
+
throw new Error('Value must be provided and must be a list of valid JSON items.')
|
|
121
165
|
}
|
|
122
166
|
|
|
123
167
|
return this.app.request
|
|
124
168
|
.post({
|
|
125
169
|
url : `${this.getBaseURL()}/contains`,
|
|
126
|
-
data:
|
|
170
|
+
data: values
|
|
127
171
|
})
|
|
128
172
|
}
|
|
129
173
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { HiveStore } from './base-store'
|
|
2
2
|
import { HiveTypes } from '../constants'
|
|
3
3
|
import Utils from '../../utils'
|
|
4
|
-
|
|
5
4
|
import { SetStore } from './set'
|
|
5
|
+
import { isHiveValueValid } from '../utils'
|
|
6
6
|
|
|
7
7
|
export class SortedSetStore extends HiveStore {
|
|
8
8
|
|
|
@@ -108,8 +108,8 @@ export class SortedSetStore extends HiveStore {
|
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
incrementScore(value, scoreValue) {
|
|
111
|
-
if (!value
|
|
112
|
-
throw new Error('Value must be provided and must be
|
|
111
|
+
if (!isHiveValueValid(value)) {
|
|
112
|
+
throw new Error('Value must be provided and must be one of types: string, number, boolean, object, array.')
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
if (isNaN(scoreValue) || typeof scoreValue !== 'number') {
|
|
@@ -127,8 +127,8 @@ export class SortedSetStore extends HiveStore {
|
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
decrementScore(value, scoreValue) {
|
|
130
|
-
if (!value
|
|
131
|
-
throw new Error('Value must be provided and must be
|
|
130
|
+
if (!isHiveValueValid(value)) {
|
|
131
|
+
throw new Error('Value must be provided and must be one of types: string, number, boolean, object, array.')
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
if (isNaN(scoreValue) || typeof scoreValue !== 'number') {
|
|
@@ -194,8 +194,8 @@ export class SortedSetStore extends HiveStore {
|
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
getScore(value) {
|
|
197
|
-
if (!value
|
|
198
|
-
throw new Error('Value must be provided and must be
|
|
197
|
+
if (!isHiveValueValid(value)) {
|
|
198
|
+
throw new Error('Value must be provided and must be one of types: string, number, boolean, object, array.')
|
|
199
199
|
}
|
|
200
200
|
|
|
201
201
|
return this.app.request
|
|
@@ -208,8 +208,8 @@ export class SortedSetStore extends HiveStore {
|
|
|
208
208
|
}
|
|
209
209
|
|
|
210
210
|
getRank(value, reverse) {
|
|
211
|
-
if (!value
|
|
212
|
-
throw new Error('Value must be provided and must be
|
|
211
|
+
if (!isHiveValueValid(value)) {
|
|
212
|
+
throw new Error('Value must be provided and must be one of types: string, number, boolean, object, array.')
|
|
213
213
|
}
|
|
214
214
|
|
|
215
215
|
if (reverse !== undefined && typeof reverse !== 'boolean') {
|
|
@@ -306,15 +306,27 @@ export class SortedSetStore extends HiveStore {
|
|
|
306
306
|
})
|
|
307
307
|
}
|
|
308
308
|
|
|
309
|
+
deleteValue(value) {
|
|
310
|
+
if (!isHiveValueValid(value)) {
|
|
311
|
+
throw new Error('Value must be provided and must be one of types: string, number, boolean, object, array.')
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
return this.app.request
|
|
315
|
+
.delete({
|
|
316
|
+
url : `${this.getBaseURL()}/values`,
|
|
317
|
+
data: [value]
|
|
318
|
+
})
|
|
319
|
+
}
|
|
320
|
+
|
|
309
321
|
deleteValues(values) {
|
|
310
|
-
if (!values || !(
|
|
311
|
-
throw new Error('Value
|
|
322
|
+
if (!values || !Array.isArray(values) || !values.length || !isHiveValueValid(values)) {
|
|
323
|
+
throw new Error('Value must be provided and must be a list of JSON items.')
|
|
312
324
|
}
|
|
313
325
|
|
|
314
326
|
return this.app.request
|
|
315
327
|
.delete({
|
|
316
328
|
url : `${this.getBaseURL()}/values`,
|
|
317
|
-
data:
|
|
329
|
+
data: values
|
|
318
330
|
})
|
|
319
331
|
}
|
|
320
332
|
|