What is query for empty documents in N1QL?

Hi,
We observed in our database, few are created with empty data documents like {}. We dont know the reasons. But first we want to find how many records are in our database.

How to find the root cause also

During insert /upsert you might have created empty document or update with unset on single field document.

SELECT META(d).id  
FROM default AS d  
WHERE d = {};

Above query gives document keys (required primary index).

DELETE FROM default AS d
WHERE d = {};

Deletes them

Thank you for your response, is there any change those are create from couchbase mobile lite?

What do you mean of unset on single field?

Not sure about mobile lite. May be you can ask in Mobile topic

Example: After unset document will not have any fields. document will be empty and select gives “k01”

insert into default values ("k01",{"a":10});
update default USE KEYS "k01" unset a;
select META(d).id from default d  USE KEYS "k01" WHERE d = {};

The following query uses ix10 as covered index. Index contain only empty objects.

CREATE INDEX ix10 ON default(OBJECT_LENGTH(self))
WHERE OBJECT_LENGTH(self) = 0;

DELETE FROM default AS d
WHERE OBJECT_LENGTH(d) = 0;