Exclude fields in SELECT clause

Is there a way to specify the fields I don’t want to fetch in SELECT clause? Something like this:

SELECT META().id, * EXCEPT password FROM myBucket WHERE type = "user"

If not… I know that this is not a SQL feature, but considering working with documents with dynamic content rather than tables with fixed fields, this cloud be a cool feature!

You have two options.

  1. Explicitly specify the projection field instead of *
  2. project as MSSING at the end of projection. If present in the document it removes
      SELECT META(b).id, b.*, MISSING AS password 
      FROM myBucket AS b
      WHERE type = "user"
2 Likes

Thank you @vsr1! Options 1 is what I want to avoid, but option 2 is exactly what i needed.

e.g.

SELECT b.*, MISSING AS `password`
FROM [{ "name": "user1" },{ "name": "user2", "password": "Field to hide" }] AS b

result:

[
  { "name": "user1" },
  { "name": "user2" }
]

FYI: In next release there is function MASK() MB-17196, DOC-8771 which might helpful in some cases. cc @dh