aerospike 5.2.0 → 5.2.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.
Files changed (60) hide show
  1. package/binding.gyp +1 -1
  2. package/lib/binding/openssl@1/node-v108-darwin-arm64/aerospike.node +0 -0
  3. package/lib/binding/openssl@1/node-v108-darwin-x64/aerospike.node +0 -0
  4. package/lib/binding/openssl@1/node-v108-linux-arm64/aerospike.node +0 -0
  5. package/lib/binding/openssl@1/node-v108-linux-x64/aerospike.node +0 -0
  6. package/lib/binding/openssl@1/node-v111-darwin-arm64/aerospike.node +0 -0
  7. package/lib/binding/openssl@1/node-v111-darwin-x64/aerospike.node +0 -0
  8. package/lib/binding/openssl@1/node-v111-linux-arm64/aerospike.node +0 -0
  9. package/lib/binding/openssl@1/node-v111-linux-x64/aerospike.node +0 -0
  10. package/lib/binding/openssl@1/node-v83-darwin-x64/aerospike.node +0 -0
  11. package/lib/binding/openssl@1/node-v83-linux-arm64/aerospike.node +0 -0
  12. package/lib/binding/openssl@1/node-v83-linux-x64/aerospike.node +0 -0
  13. package/lib/binding/openssl@1/node-v93-darwin-arm64/aerospike.node +0 -0
  14. package/lib/binding/openssl@1/node-v93-darwin-x64/aerospike.node +0 -0
  15. package/lib/binding/openssl@1/node-v93-linux-arm64/aerospike.node +0 -0
  16. package/lib/binding/openssl@1/node-v93-linux-x64/aerospike.node +0 -0
  17. package/lib/binding/openssl@3/node-v108-darwin-arm64/aerospike.node +0 -0
  18. package/lib/binding/openssl@3/node-v108-darwin-x64/aerospike.node +0 -0
  19. package/lib/binding/openssl@3/node-v108-linux-arm64/aerospike.node +0 -0
  20. package/lib/binding/openssl@3/node-v108-linux-x64/aerospike.node +0 -0
  21. package/lib/binding/openssl@3/node-v111-darwin-arm64/aerospike.node +0 -0
  22. package/lib/binding/openssl@3/node-v111-darwin-x64/aerospike.node +0 -0
  23. package/lib/binding/openssl@3/node-v111-linux-arm64/aerospike.node +0 -0
  24. package/lib/binding/openssl@3/node-v111-linux-x64/aerospike.node +0 -0
  25. package/lib/binding/openssl@3/node-v83-darwin-x64/aerospike.node +0 -0
  26. package/lib/binding/openssl@3/node-v83-linux-arm64/aerospike.node +0 -0
  27. package/lib/binding/openssl@3/node-v83-linux-x64/aerospike.node +0 -0
  28. package/lib/binding/openssl@3/node-v93-darwin-arm64/aerospike.node +0 -0
  29. package/lib/binding/openssl@3/node-v93-darwin-x64/aerospike.node +0 -0
  30. package/lib/binding/openssl@3/node-v93-linux-arm64/aerospike.node +0 -0
  31. package/lib/binding/openssl@3/node-v93-linux-x64/aerospike.node +0 -0
  32. package/lib/bitwise.js +23 -21
  33. package/lib/cdt_context.js +45 -0
  34. package/lib/exp.js +1 -1
  35. package/lib/exp_operations.js +1 -1
  36. package/lib/filter.js +1 -1
  37. package/lib/hll.js +12 -10
  38. package/lib/lists.js +151 -149
  39. package/lib/maps.js +115 -113
  40. package/lib/operations.js +1 -1
  41. package/lib/query.js +1 -1
  42. package/lib/scan.js +1 -1
  43. package/lib/status.js +7 -3
  44. package/package.json +4 -11
  45. package/scripts/build-c-client.ps1 +29 -9
  46. package/scripts/build-c-client.sh-cclient-output.log +363 -0
  47. package/scripts/postinstall.js +12 -0
  48. package/scripts/prebuiltBinding.js +73 -0
  49. package/src/include/command.h +2 -0
  50. package/src/main/async.cc +2 -1
  51. package/src/main/cdt_ctx.cc +48 -17
  52. package/src/main/command.cc +28 -0
  53. package/src/main/enums/status.cc +6 -2
  54. package/test/batch_write.js +184 -28
  55. package/test/cdt_context.js +113 -1
  56. package/test/get.js +1 -1
  57. package/test/operate.js +1 -1
  58. package/typings/autoIndex.d.ts +1709 -0
  59. package/typings/index.d.ts +1 -1
  60. package/scripts/ssl_check.sh +0 -16
package/binding.gyp CHANGED
@@ -52,7 +52,7 @@
52
52
  'action': [
53
53
  'pwsh', 'scripts/build-c-client.ps1',
54
54
  '-Configuration', "$(ConfigurationName)",
55
- '-NodeLibFile', "<(node_root_dir)/<(build_arch)/node.lib"
55
+ '-NodeLibFile', "<(node_root_dir)/<(target_arch)/node.lib"
56
56
  ]
57
57
  }
58
58
  ]
package/lib/bitwise.js CHANGED
@@ -42,26 +42,28 @@ const as = require('bindings')('aerospike.node')
42
42
  const opcodes = as.bitOperations
43
43
 
44
44
  /**
45
- * @class aerospike/bitwise~BitwiseOperation
45
+ * @class module:aerospike/bitwise~BitwiseOperation
46
46
  *
47
47
  * @classdesc Use the methods in the {@link module:aerospike/bitwise|bitwise}
48
48
  * module to create bitwise operations for use with the {@link Client#operate}
49
49
  * command.
50
50
  */
51
51
  class BitwiseOperation extends Operation {
52
- /**
53
- * @summary Applies a {@link BitwisePolicy} to the operation.
54
- *
55
- * @param {BitwisePolicy} policy - Policy to apply to the operation.
56
- */
57
- withPolicy (policy) {
58
- this.policy = policy
59
- return this
60
- }
52
+
53
+ }
54
+
55
+ /**
56
+ * @summary Applies a {@link BitwisePolicy} to the operation.
57
+ *
58
+ * @param {BitwisePolicy} policy - Policy to apply to the operation.
59
+ */
60
+ BitwiseOperation.prototype.withPolicy = function (policy) {
61
+ this.policy = policy
62
+ return this
61
63
  }
62
64
 
63
65
  /**
64
- * @class aerospike/bitwise~OverflowableBitwiseOp
66
+ * @class module:aerospike/bitwise~OverflowableBitwiseOp
65
67
  *
66
68
  * @classdesc Bitwise operation variant that can overflow/underflow.
67
69
  *
@@ -73,17 +75,17 @@ class OverflowableBitwiseOp extends BitwiseOperation {
73
75
  super(op, bin, props)
74
76
  this.overflowAction = as.bitwise.overflow.FAIL
75
77
  }
78
+ }
76
79
 
77
- /**
78
- * @summary Sets the action to take when the operation overflows/underflows.
79
- *
80
- * @param {number} action - {@link module:aerospike/bitwise.overflow|overflow
81
- * action} to apply to the operation.
82
- */
83
- onOverflow (action) {
84
- this.overflowAction = action
85
- return this
86
- }
80
+ /**
81
+ * @summary Sets the action to take when the operation overflows/underflows.
82
+ *
83
+ * @param {number} action - {@link module:aerospike/bitwise.overflow|overflow
84
+ * action} to apply to the operation.
85
+ */
86
+ OverflowableBitwiseOp.prototype.onOverflow = function (action) {
87
+ this.overflowAction = action
88
+ return this
87
89
  }
88
90
 
89
91
  /**
@@ -66,6 +66,33 @@ class CdtContext {
66
66
  return this.add(LIST_INDEX, index)
67
67
  }
68
68
 
69
+ /**
70
+ * @summary Lookup list by base list's index offset.
71
+ *
72
+ * @description If the list at index offset is not found,
73
+ * create it with the given sort order at that index offset.
74
+ * If pad is true and the index offset is greater than the
75
+ * bounds of the base list, nil entries will be inserted before the newly
76
+ * created list.
77
+ *
78
+ * @param {number} index - List index
79
+ * @param {number} order - Sort order used if a list is created
80
+ * @param {boolean} pad - Pads list entries between index and the
81
+ * final list entry with zeros.
82
+ * @return {CdtContext} Updated CDT context, so calls can be chained.
83
+ */
84
+ addListIndexCreate (index, order, pad) {
85
+ if (order) {
86
+ return this.add(LIST_INDEX | 0xc0, index)
87
+ } else {
88
+ if (pad) {
89
+ return this.add(LIST_INDEX | 0x80, index)
90
+ } else {
91
+ return this.add(LIST_INDEX | 0x40, index)
92
+ }
93
+ }
94
+ }
95
+
69
96
  /**
70
97
  * @summary Lookup list by rank.
71
98
  *
@@ -137,6 +164,24 @@ class CdtContext {
137
164
  return this.add(MAP_KEY, key)
138
165
  }
139
166
 
167
+ /**
168
+ * @summary Lookup map by base map's key. If the map at key is not found,
169
+ * create it with the given sort order at that key.
170
+ *
171
+ * @param {any} key - Map key
172
+ * @param {number} order - Sort order used if a map is created
173
+ * @return {CdtContext} Updated CDT context, so calls can be chained.
174
+ */
175
+ addMapKeyCreate (key, order) {
176
+ if (!order) {
177
+ return this.add(MAP_KEY | 0x40, key)
178
+ } else if (order === 1) {
179
+ return this.add(MAP_KEY | 0x80, key)
180
+ } else {
181
+ return this.add(MAP_KEY | 0xc0, key)
182
+ }
183
+ }
184
+
140
185
  /**
141
186
  * @summary Lookup map by value.
142
187
  *
package/lib/exp.js CHANGED
@@ -623,7 +623,7 @@ exports.mul = _VAExp(exp.ops.MUL)
623
623
  exports.div = _VAExp(exp.ops.DIV)
624
624
 
625
625
  const _paramsExp = (op) => (...params) => [
626
- { op: op, count: params.length + 1 },
626
+ { op, count: params.length + 1 },
627
627
  ...params
628
628
  ]
629
629
 
@@ -71,7 +71,7 @@ const ops = as.expOperations
71
71
 
72
72
  /**
73
73
  * @protected
74
- * @class aerospike/exp_operations~ExpOperation
74
+ * @class module:aerospike/exp_operations~ExpOperation
75
75
  *
76
76
  * @classdesc class for all expression operations executed with the {@link
77
77
  * Client#operate} command.
package/lib/filter.js CHANGED
@@ -46,7 +46,7 @@ const GeoJSON = require('./geojson')
46
46
  */
47
47
 
48
48
  /**
49
- * @class aerospike/filter~SindexFilterPredicate
49
+ * @class module:aerospike/filter~SindexFilterPredicate
50
50
  * @classdesc SI filter predicate to limit the scope of a {@link Query}.
51
51
  *
52
52
  * Filter predicates must be instantiated using the methods in the {@link
package/lib/hll.js CHANGED
@@ -108,22 +108,24 @@ const GET_SIMILARITY_COMMAND = 54
108
108
  const DESCRIBE_COMMAND = 55
109
109
 
110
110
  /**
111
- * @class aerospike/hll~HLLOperation
111
+ * @class module:aerospike/hll~HLLOperation
112
112
  *
113
113
  * @classdesc Use the methods in the {@link module:aerospike/hll|hll}
114
114
  * module to create HLL operations for use with the {@link Client#operate}
115
115
  * command.
116
116
  */
117
117
  class HLLOperation extends Operation {
118
- /**
119
- * @summary Applies a {@link HLLPolicy} to the operation.
120
- *
121
- * @param {HLLPolicy} policy - Policy to apply to the operation.
122
- */
123
- withPolicy (policy) {
124
- this.policy = policy
125
- return this
126
- }
118
+
119
+ }
120
+
121
+ /**
122
+ * @summary Applies a {@link HLLPolicy} to the operation.
123
+ *
124
+ * @param {HLLPolicy} policy - Policy to apply to the operation.
125
+ */
126
+ HLLOperation.prototype.withPolicy = function (policy) {
127
+ this.policy = policy
128
+ return this
127
129
  }
128
130
 
129
131
  /**
package/lib/lists.js CHANGED
@@ -61,164 +61,166 @@ const AerospikeError = require('./error')
61
61
  const Operation = require('./operations').Operation
62
62
 
63
63
  /**
64
- * @class aerospike/lists~ListOperation
64
+ * @class module:aerospike/lists~ListOperation
65
65
  *
66
66
  * @classdesc Use the methods in the {@link module:aerospike/lists|lists}
67
67
  * module to create list operations for use with the {@link Client#operate}
68
68
  * command.
69
69
  */
70
70
  class ListOperation extends Operation {
71
- /**
72
- * @summary Set the return type for certain list operations.
73
- * @description The return type only affects <code>getBy\*</code> and
74
- * <code>removeBy\*</code> list operations.
75
- *
76
- * @param {number} returnType - The {@link
77
- * module:aerospike/lists.returnType|return type} indicating what data of the
78
- * selected items to return.
79
- *
80
- * @example <caption>Fetch the first three list elements and return the values</caption>
81
- *
82
- * const Aerospike = require('aerospike')
83
- * const lists = Aerospike.lists
84
- * const key = new Aerospike.Key('test', 'demo', 'listsTest')
85
- * // INSERT HOSTNAME AND PORT NUMBER OF AEROSPIKE SERVER NODE HERE!
86
- * var config = {
87
- * hosts: '192.168.33.10:3000',
88
- * // Timeouts disabled, latency dependent on server location. Configure as needed.
89
- * policies: {
90
- * write : new Aerospike.WritePolicy({socketTimeout : 0, totalTimeout : 0}),
91
- * operate : new Aerospike.OperatePolicy({socketTimeout : 0, totalTimeout : 0})
92
- * }
93
- * }
94
- * Aerospike.connect(config).then(async client => {
95
- * await client.put(key, { list: [32, 5, 85, 16, 22] })
96
- * const ops = [
97
- * lists.getByValueRange('list', 10, 30)
98
- * .andReturn(lists.returnType.VALUE)
99
- * ]
100
- * const result = await client.operate(key, ops)
101
- * console.log('Result:', result.bins.list) // => Result: [ 16, 22 ]
102
- * client.close()
103
- * })
104
- */
105
- andReturn (returnType) {
106
- this.returnType = returnType
107
- return this
108
- }
109
71
 
110
- /**
111
- * @summary By setting the context, the list operation will be executed on a
112
- * nested list, instead of the bin value itself.
113
- *
114
- * @param { CdtContext | function } context - Either a Context object, or a
115
- * function which accepts a Context object.
116
- * @returns { ListOperation } The list operation itself.
117
- *
118
- * @since v3.12.0
119
- *
120
- * @example <caption>Fetch the 1st element of the 2nd nested list</caption>
121
- *
122
- * const Aerospike = require('aerospike')
123
- * const lists = Aerospike.lists
124
- * const key = new Aerospike.Key('test', 'demo', 'listsTest')
125
- * // INSERT HOSTNAME AND PORT NUMBER OF AEROSPIKE SERVER NODE HERE!
126
- * var config = {
127
- * hosts: '192.168.33.10:3000',
128
- * // Timeouts disabled, latency dependent on server location. Configure as needed.
129
- * policies: {
130
- * write : new Aerospike.WritePolicy({socketTimeout : 0, totalTimeout : 0}),
131
- * operate : new Aerospike.OperatePolicy({socketTimeout : 0, totalTimeout : 0})
132
- * }
133
- * }
134
- * Aerospike.connect(config).then(async (client) => {
135
- * await client.put(key, { list: [[32, 5, 85], [16, 22]] })
136
- * const ops = [
137
- * lists.get('list', 0)
138
- * .withContext((ctx) => ctx.addListIndex(1))
139
- * ]
140
- * const result = await client.operate(key, ops)
141
- * console.log('Result:', result.bins.list) // => Result: 16
142
- * client.close()
143
- * })
144
- *
145
- * @example <caption>Fetch the last element of the nested list stored under the 'nested' map key</caption>
146
- *
147
- * const Aerospike = require('aerospike')
148
- * const lists = Aerospike.lists
149
- * const Context = Aerospike.cdt.Context
150
- * const key = new Aerospike.Key('test', 'demo', 'listsTest')
151
- * // INSERT HOSTNAME AND PORT NUMBER OF AEROSPIKE SERVER NODE HERE!
152
- * var config = {
153
- * hosts: '192.168.33.10:3000',
154
- * // Timeouts disabled, latency dependent on server location. Configure as needed.
155
- * policies: {
156
- * write : new Aerospike.WritePolicy({socketTimeout : 0, totalTimeout : 0}),
157
- * operate : new Aerospike.OperatePolicy({socketTimeout : 0, totalTimeout : 0})
158
- * }
159
- * }
160
- * Aerospike.connect(config).then(async (client) => {
161
- * await client.put(key, { map: { nested: [32, 5, 85, 16, 22] } })
162
- * const context = new Context().addMapKey('nested')
163
- * const ops = [
164
- * lists.get('map', -1)
165
- * .withContext(context)
166
- * ]
167
- * const result = await client.operate(key, ops)
168
- * console.log('Result:', result.bins.map) // => Result: 22
169
- * client.close()
170
- * })
171
- */
172
- withContext (contextOrFunction) {
173
- if (contextOrFunction instanceof Context) {
174
- this.context = contextOrFunction
175
- } else if (typeof contextOrFunction === 'function') {
176
- this.context = new Context()
177
- contextOrFunction(this.context)
178
- } else {
179
- throw new AerospikeError('Context param must be a CDT Context or a function that accepts a context')
180
- }
181
- return this
182
- }
72
+ }
183
73
 
184
- /**
185
- * @summary Inverts the selection of items for certain list operations.
186
- * @description For <code>getBy\*</code> and <code>removeBy\*</code> list
187
- * operations, calling the <code>invertSelect</code> method on the
188
- * <code>ListOperation</code> has the effect of inverting the selection of
189
- * list elements that the operation affects.
190
- *
191
- * @throws {AerospikeError} if the operation is not invertible.
192
- *
193
- * @example <caption>Remove all tags except for yellow from the record</caption>
194
- *
195
- * const Aerospike = require('aerospike')
196
- * const lists = Aerospike.lists
197
- * const key = new Aerospike.Key('test', 'demo', 'listsTest')
198
- * // INSERT HOSTNAME AND PORT NUMBER OF AEROSPIKE SERVER NODE HERE!
199
- * var config = {
200
- * hosts: '192.168.33.10:3000',
201
- * // Timeouts disabled, latency dependent on server location. Configure as needed.
202
- * policies: {
203
- * write : new Aerospike.WritePolicy({socketTimeout : 0, totalTimeout : 0}),
204
- * operate : new Aerospike.OperatePolicy({socketTimeout : 0, totalTimeout : 0})
205
- * }
206
- * }
207
- * Aerospike.connect(config).then(async client => {
208
- * await client.put(key, { tags: ['blue', 'yellow', 'pink'] })
209
- * const ops = [
210
- * lists.removeByValue('tags', 'yellow')
211
- * .invertSelection()
212
- * ]
213
- * await client.operate(key, ops)
214
- * const record = await client.get(key)
215
- * console.log('Result:', record.bins.tags) // => Result: [ 'yellow' ]
216
- * client.close()
217
- * })
218
- */
219
- invertSelection () {
220
- throw new AerospikeError(`List operation cannot be inverted [op ${this.op}]`)
74
+ /**
75
+ * @summary Inverts the selection of items for certain list operations.
76
+ * @description For <code>getBy\*</code> and <code>removeBy\*</code> list
77
+ * operations, calling the <code>invertSelect</code> method on the
78
+ * <code>ListOperation</code> has the effect of inverting the selection of
79
+ * list elements that the operation affects.
80
+ *
81
+ * @throws {AerospikeError} if the operation is not invertible.
82
+ *
83
+ * @example <caption>Remove all tags except for yellow from the record</caption>
84
+ *
85
+ * const Aerospike = require('aerospike')
86
+ * const lists = Aerospike.lists
87
+ * const key = new Aerospike.Key('test', 'demo', 'listsTest')
88
+ * // INSERT HOSTNAME AND PORT NUMBER OF AEROSPIKE SERVER NODE HERE!
89
+ * var config = {
90
+ * hosts: '192.168.33.10:3000',
91
+ * // Timeouts disabled, latency dependent on server location. Configure as needed.
92
+ * policies: {
93
+ * write : new Aerospike.WritePolicy({socketTimeout : 0, totalTimeout : 0}),
94
+ * operate : new Aerospike.OperatePolicy({socketTimeout : 0, totalTimeout : 0})
95
+ * }
96
+ * }
97
+ * Aerospike.connect(config).then(async client => {
98
+ * await client.put(key, { tags: ['blue', 'yellow', 'pink'] })
99
+ * const ops = [
100
+ * lists.removeByValue('tags', 'yellow')
101
+ * .invertSelection()
102
+ * ]
103
+ * await client.operate(key, ops)
104
+ * const record = await client.get(key)
105
+ * console.log('Result:', record.bins.tags) // => Result: [ 'yellow' ]
106
+ * client.close()
107
+ * })
108
+ */
109
+ ListOperation.prototype.invertSelection = function () {
110
+ throw new AerospikeError(`List operation cannot be inverted [op ${this.op}]`)
111
+ }
112
+
113
+ /**
114
+ * @summary By setting the context, the list operation will be executed on a
115
+ * nested list, instead of the bin value itself.
116
+ *
117
+ * @param { CdtContext | function } context - Either a Context object, or a
118
+ * function which accepts a Context object.
119
+ * @returns { ListOperation } The list operation itself.
120
+ *
121
+ * @since v3.12.0
122
+ *
123
+ * @example <caption>Fetch the 1st element of the 2nd nested list</caption>
124
+ *
125
+ * const Aerospike = require('aerospike')
126
+ * const lists = Aerospike.lists
127
+ * const key = new Aerospike.Key('test', 'demo', 'listsTest')
128
+ * // INSERT HOSTNAME AND PORT NUMBER OF AEROSPIKE SERVER NODE HERE!
129
+ * var config = {
130
+ * hosts: '192.168.33.10:3000',
131
+ * // Timeouts disabled, latency dependent on server location. Configure as needed.
132
+ * policies: {
133
+ * write : new Aerospike.WritePolicy({socketTimeout : 0, totalTimeout : 0}),
134
+ * operate : new Aerospike.OperatePolicy({socketTimeout : 0, totalTimeout : 0})
135
+ * }
136
+ * }
137
+ * Aerospike.connect(config).then(async (client) => {
138
+ * await client.put(key, { list: [[32, 5, 85], [16, 22]] })
139
+ * const ops = [
140
+ * lists.get('list', 0)
141
+ * .withContext((ctx) => ctx.addListIndex(1))
142
+ * ]
143
+ * const result = await client.operate(key, ops)
144
+ * console.log('Result:', result.bins.list) // => Result: 16
145
+ * client.close()
146
+ * })
147
+ *
148
+ * @example <caption>Fetch the last element of the nested list stored under the 'nested' map key</caption>
149
+ *
150
+ * const Aerospike = require('aerospike')
151
+ * const lists = Aerospike.lists
152
+ * const Context = Aerospike.cdt.Context
153
+ * const key = new Aerospike.Key('test', 'demo', 'listsTest')
154
+ * // INSERT HOSTNAME AND PORT NUMBER OF AEROSPIKE SERVER NODE HERE!
155
+ * var config = {
156
+ * hosts: '192.168.33.10:3000',
157
+ * // Timeouts disabled, latency dependent on server location. Configure as needed.
158
+ * policies: {
159
+ * write : new Aerospike.WritePolicy({socketTimeout : 0, totalTimeout : 0}),
160
+ * operate : new Aerospike.OperatePolicy({socketTimeout : 0, totalTimeout : 0})
161
+ * }
162
+ * }
163
+ * Aerospike.connect(config).then(async (client) => {
164
+ * await client.put(key, { map: { nested: [32, 5, 85, 16, 22] } })
165
+ * const context = new Context().addMapKey('nested')
166
+ * const ops = [
167
+ * lists.get('map', -1)
168
+ * .withContext(context)
169
+ * ]
170
+ * const result = await client.operate(key, ops)
171
+ * console.log('Result:', result.bins.map) // => Result: 22
172
+ * client.close()
173
+ * })
174
+ */
175
+ ListOperation.prototype.withContext = function (contextOrFunction) {
176
+ if (contextOrFunction instanceof Context) {
177
+ this.context = contextOrFunction
178
+ } else if (typeof contextOrFunction === 'function') {
179
+ this.context = new Context()
180
+ contextOrFunction(this.context)
181
+ } else {
182
+ throw new AerospikeError('Context param must be a CDT Context or a function that accepts a context')
221
183
  }
184
+ return this
185
+ }
186
+
187
+ /**
188
+ * @summary Set the return type for certain list operations.
189
+ * @description The return type only affects <code>getBy\*</code> and
190
+ * <code>removeBy\*</code> list operations.
191
+ *
192
+ * @param {number} returnType - The {@link
193
+ * module:aerospike/lists.returnType|return type} indicating what data of the
194
+ * selected items to return.
195
+ *
196
+ * @example <caption>Fetch the first three list elements and return the values</caption>
197
+ *
198
+ * const Aerospike = require('aerospike')
199
+ * const lists = Aerospike.lists
200
+ * const key = new Aerospike.Key('test', 'demo', 'listsTest')
201
+ * // INSERT HOSTNAME AND PORT NUMBER OF AEROSPIKE SERVER NODE HERE!
202
+ * var config = {
203
+ * hosts: '192.168.33.10:3000',
204
+ * // Timeouts disabled, latency dependent on server location. Configure as needed.
205
+ * policies: {
206
+ * write : new Aerospike.WritePolicy({socketTimeout : 0, totalTimeout : 0}),
207
+ * operate : new Aerospike.OperatePolicy({socketTimeout : 0, totalTimeout : 0})
208
+ * }
209
+ * }
210
+ * Aerospike.connect(config).then(async client => {
211
+ * await client.put(key, { list: [32, 5, 85, 16, 22] })
212
+ * const ops = [
213
+ * lists.getByValueRange('list', 10, 30)
214
+ * .andReturn(lists.returnType.VALUE)
215
+ * ]
216
+ * const result = await client.operate(key, ops)
217
+ * console.log('Result:', result.bins.list) // => Result: [ 16, 22 ]
218
+ * client.close()
219
+ * })
220
+ */
221
+ ListOperation.prototype.andReturn = function (returnType) {
222
+ this.returnType = returnType
223
+ return this
222
224
  }
223
225
 
224
226
  /**