From c5d0c63051ce7506bd57cb3c138716d4a0046244 Mon Sep 17 00:00:00 2001
From: Dominic Pelini <111786059+DomPeliniAerospike@users.noreply.github.com>
Date: Wed, 1 Nov 2023 10:49:34 -0600
Subject: [PATCH] Added maps.create method
CLIENT-2617
Added maps.create method
Added persitIndex as a parameter
---
lib/maps.js | 26 ++++++++++++++++++++++++++
src/main/map_operations.cc | 27 +++++++++++++++++++++++++--
test/maps.js | 34 ++++++++++++++++++++++++++++++++++
3 files changed, 85 insertions(+), 2 deletions(-)
diff --git a/lib/maps.js b/lib/maps.js
index 0b9c40987..8c6c52e7a 100644
--- a/lib/maps.js
+++ b/lib/maps.js
@@ -1275,3 +1275,29 @@ exports.getByRankRange = function (bin, rank, count, returnType) {
op.returnType = returnType
return op
}
+
+/**
+ * @summary Retrieves one or more items in the specified rank range from the
+ * map.
+ *
+ * @description This operation returns the data specified by
+ * returnType.
+ *
+ * @param {string} bin - The name of the bin, which must contain a Map value.
+ * @param {number} index - Starting rank.
+ * @param {number} count - Number of items to delete; if not specified, the
+ * range includes all items starting from rank.
+ * @param {number} [returnType] - The {@link module:aerospike/maps.returnType|return type}
+ * indicating what data of the selected item(s) to return.
+ * @returns {Object} Operation that can be passed to the {@link Client#operate} command.
+ *
+ * @see Instead of passing returnType, you can also use
+ * {@link module:aerospike/maps~MapOperation#andReturn|MapOperation#andReturn} to
+ * select what data to return.
+ */
+exports.create = function (bin, order, persistIndex=false) {
+ const op = new MapOperation(opcodes.MAP_CREATE, bin)
+ op.order = order
+ op.persistIndex = persistIndex
+ return op
+}
diff --git a/src/main/map_operations.cc b/src/main/map_operations.cc
index ab244d5a9..afc51f6da 100644
--- a/src/main/map_operations.cc
+++ b/src/main/map_operations.cc
@@ -1027,6 +1027,28 @@ bool add_map_get_by_rank_range_op(as_operations *ops, const char *bin,
return true;
}
+bool add_map_create_op(as_operations *ops, const char *bin,
+ as_cdt_ctx *context, Local