Is their a way to auto generate document with type designator attribute like in mongo DB?

Is their a way to auto generate document with type designator attribute like in mongo DB?

@shreyas.sangai,

In Couchbase schema is dictated by the application when it insert data.

Hence it cannot determine the type? So we have to manually add the type attribute? AFAIK mongo DB also supports schema less documents. Any advantage of not having the type attribute automatically inserted?

Could you demonstrate how mongo automatically adds type attribute?

I think I may I have confused it with the objectId which is autogenerated : https://docs.mongodb.com/v3.2/tutorial/insert-documents/#id-field. So I think my bad?

I am using spring data which as it turns out does add the _class attribute automatically. So my problem is solved.
https://docs.spring.io/spring-data/couchbase/docs/current/reference/html/#couchbase.repository.indexing.

Reason we need the type of document (atleast I think we need) is for indexing. Otherwise how does Couchbase handle retrieval of the same attributes in different documents? How do I differentiate between the data while retrieving since we have one bucket for all kinds of docs (In mongo db we have collections which is same as tables) So for eg we have Teacher and student doc with name field. I would create an index on name field where doc type is teacher (thats possible to do right) to retrieve all teacher names else it will give all the names. Am I in the right direction?