Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Couchbase N1QL: Retrieve documents that do not have a specific field

Tags:

couchbase

n1ql

I have many documents in a bucket as

{ prop1: value, prop2: value, prop3: value}

But some documents do not have the prop3 field.

How can I retrieve all documents that DO NOT have the prop3 field, using an n1ql query?

like image 686
Srirag Nair Avatar asked Dec 11 '22 15:12

Srirag Nair


1 Answers

The IS MISSING keyword is your friend here:

SELECT * FROM bucket WHERE prop3 IS MISSING;
like image 165
Simon Baslé Avatar answered May 12 '23 11:05

Simon Baslé