Reputation: 523
I know the syntax to insert a document in to Couchbase using a n1ql INSERT statement if the values are single values:
INSERT INTO `travel-sample` ( KEY, VALUE )
VALUES
(
"k001",
{ "id": "01", "type": "airline"}
)
RETURNING META().id as docid, *;
But what if one of the values is an array of strings, what is the syntax for that? I haven't been able to find an example any where on the couchbase website or anywhere else.
Upvotes: 2
Views: 3110
Reputation: 7414
There syntax for array is same as JSON syntax
Example:
reviews field is ARRAY of strings
INSERT INTO `travel-sample` ( KEY, VALUE ) VALUES (
"k001", { "id": "01", "type": "airline", "reviews": ["xyz", "abc"] });
Document it self is ARRAY not a OBJECT
INSERT INTO `travel-sample` ( KEY, VALUE ) VALUES (
"k002", ["xyz", "abc"]);
Upvotes: 3