In MariaDB, JSON_ARRAY()
is a built-in function that returns a JSON array containing the specified values, provided as arguments.
Tag: arrays
Fix “$pullAll requires an array argument but was given a double” in MongoDB
If you get the “$pullAll requires an array argument but was given a double” error in MongoDB, it’s because you didn’t provide an array as the value to replace.
Continue reading3 Ways to Remove a Value from an Array in MongoDB
MongoDB provides a few operators that enable you to remove values from arrays.
These include:
$pull
$pullAll
$pop
2 Ways to Append a Value to an Array in MongoDB
If you have a collection of documents in MongoDB that contain arrays, you can add new values to those arrays if required.
Depending on your specific requirements, you can use the $push
operator or the $addToSet
operator.
MongoDB $isArray
In MongoDB you can use the $isArray
aggregation pipeline operator to check whether or not a value is an array.
It accepts any valid expression, and returns true
if the expression is an array, false
if it’s not.
MongoDB $indexOfArray
In MongoDB, the $indexOfArray
aggregation pipeline operator searches an array for an occurrence of a specified value and returns the array index of the first occurrence.
MongoDB $arrayToObject
In MongoDB, the $arrayToObject
aggregation pipeline operator converts an array to a document.
MongoDB $objectToArray
In MongoDB, the $objectToArray
aggregation pipeline operator converts a document to an array.
MongoDB $reverseArray
In MongoDB, the $reverseArray
aggregation pipeline operator reverses the order of items in an array.
It accepts an array expression as an argument and returns an array with the elements in reverse order.
Continue readingImport Documents into MongoDB from an Array of JSON Documents
When using mongoimport
, you can use the --jsonArray
parameter to import an array of JSON documents.