Create an ObjectId in Trigger Function

I have two ObjectId in my document. One is getting created automatically while inserting the data in a collection. But the other one I need to generate manually. Everything is happening inside a trigger function.

Can anyone help me out that how can I generate ObjectId manually inside my trigger function so that I can insert document in my respective collection.
Urgent help is required. In case of any detail is required kindly le me know.

Thanks in advance.

Hi @Ankit_Rana,

Welcome to the community :wave:

To generate a ObjectId you can use the BSON module which is already included as a global module in Realm functions.

const generatedObjectId = new BSON.ObjectId();

Hope this helps :slightly_smiling_face:


1 Like

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