-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A query to update a field in all documents with a unique id #5
Comments
Can you look into this. |
UUID() is not defined in Mongo by default and instead of using split, we can do this. We can import the 'uuid' library in JS. Then the generated UUIDs are already returned as strings without double quotes therefore this split part will be unnecessary. We can use 'uuid.v4()'. Then this generated UUID can be assigned to the 'unique_id' field. By removing the split, I believe we can reduce errors which can be caused by certain edge case scenarios as well. This can be the updated code:
I found these as well: |
@SayuruRehan Okay add the updated version. But first try it out yourself to see if it works. Also mention the following in a convenient way.
|
@SayuruRehan Please correct me if I'm wrong. The function we define in the body is not run on our backend server but in MondoDB. So I don't think this https://www.mongodb.com/docs/manual/reference/method/UUID/ And also it's mentioned that MongoDB's js engine is based on SpiderMonkey from Mozilla instead of Chrome's V8 on which Node.js is built on. So I'm not sure even if somehow we imported uuid into the code from the node package you mentioned it's gonna work at all. Refer the first comment in the following question for more details. |
The text was updated successfully, but these errors were encountered: