Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 64 additions & 7 deletions modules/n1ql/pages/n1ql-language-reference/objectfun.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,12 @@ If any of the input objects contain the same attribute name, the attribute from
.Query
[source,sqlpp]
----
SELECT OBJECT_CONCAT({"abc": 1}, {"def": 2}, {"ghi": 3}, {"ghi": 4}, {"ghi": [5, 6, 7]});
SELECT OBJECT_CONCAT({"flight": "AF198"},
{"utc": "4:44:44"},
{"code": "green"},
{"code": "yellow"},
{"passengers": ["Corrine Hill", "Vallie Ryan"]}
);
----

.Results
Expand All @@ -96,19 +101,71 @@ SELECT OBJECT_CONCAT({"abc": 1}, {"def": 2}, {"ghi": 3}, {"ghi": 4}, {"ghi": [5,
[
{
"$1": {
"abc": 1,
"def": 2,
"ghi": [
5,
6,
7
"flight": "AF198",
"utc": "4:44:44",
"code": "yellow",
"passengers": [
"Corrine Hill",
"Vallie Ryan"
]
}
}
]
----
====

[[fn-obj-concat2,OBJECT_CONCAT2()]]
== OBJECT_CONCAT2(`expr`, `expr` ...)

=== Description

This function concatenates multiple input objects into a single new object, and requires at least two input objects to work.
Unlike <<fn-obj-concat>>, this function supports both plain objects and arrays of objects as arguments.


=== Arguments

expr:: An expression representing an object or an array of objects.
The first argument must be a plain object and cannot be an array.

=== Return Value

An object constructed by concatenating all the input objects.
If any of the input objects contain the same attribute name, the attribute from the last relevant object in the input list is copied to the output; similarly-named attributes from earlier objects in the input list are ignored.

=== Examples

[[obj-concat2-ex,OBJECT_CONCAT2() Example]]
====
.Query
[source,sqlpp]
----
SELECT OBJECT_CONCAT2(
{"flight": "AF198"},
[ {"utc": "4:44:44"},
{"code": "green"},
{"airline": "Air France"},
{"airline": "Delta"}
]
);
----

.Results
[source,json]
----
[
{
"$1": {
"flight": "AF198",
"utc": "4:44:44",
"code": "green",
"airline": "Delta"
}
}
]
----
====

[[fn-obj-field,OBJECT_FIELD()]]
== OBJECT_FIELD(`object`, `field`)

Expand Down