n1ql

Couchbase N1QL join query

匆匆过客 提交于 2019-12-01 01:18:39
need help with a query in Couchbase enviroment. Both document 1 and document 2 is in the same bucket. First the query will get the document message1 using this query: SELECT uid, message, sent_by FROM bucket USE KEYS "message1" Second, it need to get username from document 2. How can i create a join statement that will fetch username from a given document name, using the query above? Overview Document 1 document name = message1 [ { "uid": "1", "message": "hello", "sent_by": "username" } ] Document 2 document name = user1 [ { "username": "username" } ] Assuming that the name of Document2 is

n1ql query to update multiple parameters in array of json data

我只是一个虾纸丫 提交于 2019-11-30 16:48:19
Following is the sample document ( userdetails) in couchbase. { "friends": [ { "company": "microsoft", "firstname": "criss", "lastname": "angel" }, { "company": "google", "firstname": "captain", "lastname": "america" } ]} based on the "company", i want to change the "firstname" and "lastname" N1ql query ( to update single parameter (firstname) ) update default use keys "userdetails" set a.firstname="xyz" for a in friends when a.company="microsoft" end returning friends Above query works perfectly. but Im struggling in writting query for updating two parameters ( firstname,lastname) N1ql query

n1ql query to update multiple parameters in array of json data

一曲冷凌霜 提交于 2019-11-29 23:20:32
问题 Following is the sample document ( userdetails) in couchbase. { "friends": [ { "company": "microsoft", "firstname": "criss", "lastname": "angel" }, { "company": "google", "firstname": "captain", "lastname": "america" } ]} based on the "company", i want to change the "firstname" and "lastname" N1ql query ( to update single parameter (firstname) ) update default use keys "userdetails" set a.firstname="xyz" for a in friends when a.company="microsoft" end returning friends Above query works

N1ql -> IN operator does not work with other conditions

本秂侑毒 提交于 2019-11-28 08:12:14
问题 The following query works just fine when only IN operator is used SELECT META().id FROM bucket_name WHERE description IN ['Item1','Item2'] But when I fire this query it gives me a blank result SELECT META().id FROM bucket_name WHERE id = 123 AND description IN ['Item1','Item2'] Am I doing something wrong or somebody else has faced the same problem? 回答1: I think you have to take your "IN" condition into parenthesis to make it work: SELECT META().id FROM bucket_name WHERE id = 123 AND