The Logical Type of The Document


Currently I’m putting a document type, inside the document itself, inside a string field named Type like say Product.

But I see this pattern of using separators in document id, like product::app::123id. Done some playing around it, couldn’t get the type part (product) from the key (Of-course parsing it, by splitting is possible, which to me seems to have same overhead).

So how should the document type (app logic type) get specified?

Note: This probably has got discussed before, but I could not find it and meta.type actually returns the kind of document and doc.type does not exists for such ids. Please accept my apologies in advance if I’ve missed something.

Env: CouchBase Community, inside Docker on Ubuntu 14.04, using Go client gocb.

Are you trying to do it in N1QL query? or in which context?

Inside both views and N1QL - Does this mean I should have two (or more?) ways to specify the logical type of a document?

Just for the record and for the future reference, Matthew Groves provided a good answer to this.

1 Like