The question is vague. You have not given any context of what you are doing? Give me an example and how you would like to see in MongoDB.
In Teiid with MongoDB as source, the Primary Key of the table maps to the "_id" field in MongoDB. If you do not have a Primary Key then MongoDB still creates one implicitly in document model. With MongoDB, to manage relations from Table A to Table B, they need to be designed as such and define related extension properties carefully. Read and understand from here . If you already have a document model in MongoDB then try using metadata import feature to design to Table structure automatically.
Thank you for replying my question, the example is like bellow, the field parentid were referenced by _id, the front 4 rows were generated manually, these types of parentid were what I expected, but the bellow rows were generated by teiid, it becomes to string type.
The table defineation is :
Part of virtual procedure clause is:
LOOP ON (SELECT CommonSrcOrganization.GY_KSDM.KSDM, CommonSrcOrganization.GY_KSDM.SJKS FROM CommonSrcOrganization.GY_KSDM) AS ksrow
UPDATE GuanZhong.Organization SET parentId = (SELECT GuanZhong.Organization.id FROM GuanZhong.Organization WHERE GuanZhong.Organization.code = convert(ksrow.SJKS, string)) WHERE GuanZhong.Organization.code = convert(ksrow.KSDM, string);
If the document is already in the MongoDB, then use
File -> Import -> Teiid Designer -> Teiid Connection >> Source Model
and point to the MongoDB database, and use translator mongodb and import metadata. That will generate correct metadata to begin with.
Thank you for pointing me the operation step, I've followed the step to import MongoDB metadata, but it effects the same as I manually created metadata, the field parentId were assigned with field "_id", but it was saved into hex string type instead of ObjectId type. I want to save it into ObjectId type so that out client developer can correctly access the data.
How did you create a connection to MongoDB in the Teiid Server. When using the above procedure, the first step is to select or create a connection. There you need to create a MongoDB connection and use that. If there already connection based some other JDBC drivers Teiid does not support that. So, try creating a new connection and using that from Designer. Otherwise look into Teiid documentation here  on how to create MongoDB connection on the server without Designer and select the JNDI name during the import.
Hi, Ramesh, I created the connection to MongoDB using mongodb translator, and I followed your step to import the source model, the ObjectId fields were imported as object type. but when I save the ObjectId field references from other ObjectId field using UPDATE clause, the updated ObjectId field value becomes hex string formation, I guess the ObjectId that referenced were convert into hex string by mongodb translator, I don't know what formation of ObjectId field were stored to mongo db, I'm thinking of a solution to convert the hex string type ObjectId field data into the right formation that would be saved to mongo db, will you please give me some suggestion to solve this problem?
According to my code I set the ObjectId as String , I am not sure how it is being converted to Object. You can try converting all the "_id" fields as String, and then set native type as "org.bson.types.ObjectId" and auto increment to true. If that does not work I would have debug and see why that is the case.