Couchbase: skip certain fields while inserting a document

Is it possible in the Couchbase to provide a template that ensures documents are not inserted if the __t=irdb-net and gsm field is missing or null?

What you’re asking for is schema validation; Couchbase is schema-less.

You may be able to write an Eventing function that deletes inserted (or updated) documents that lack the criteria you specify.

In additions above reply, conditional inserts not allowed one option is use INSERT INTO SELECT

INSERT INTO default (KEY k, VALUE v)
SELECT $1 AS k, $2 AS v  FROM $2 AS t
WHERE  IFMIISINGORNULL(t.__type, "") != "irdb-net" OR t.gsm IS VALUED;

SDKs that directly use KV insert do insert only after condition satisfied. This is recommended because no over head on cluster and small code change in SDKs.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.