Trouble with Mongoose library minjs cdn

I wanted to convert a array of string object ids to array of mongo object ids so I followed below approach-
I have added mongoose CDN -

and I have written a code

let abc = []
return abc;

but when I run it nothing is returned and no error is being showed , so I tried the code on normal javascript file(Not retool), that seems to be working fine, so any suggestions if I have missed something?

Hey @Balachandra!

Happy to help here! It looks like this should work :thinking:, are you getting any errors in the browser console?

Thats the thing , no errors , i only get- query ran successfully, message no errors, but there will be no output

Hey @Balachandra — sorry for the slow reply here, I'm also having a hard time specifically with ObjectIds. I'm able to get other things to work from this library like from the quickstart guide running the following logs the correct thing in the console :thinking:

All Javascript is run in a sandbox so this can at times be the determining factor of whether external JS libraries will work but its odd that some of this works and other methods don't. I'm not the most familiar with this library though. Would you mind telling me a little more about your use case here?\

Thank you for the reply @Chris-Thompson , My use case is that I'm using it to convert the object ids which are in string format to mongo object id format, the object ids were stored in sql database so the object ids were in string format , now when I want to use it in mongodb query it has to be in format of mongo object id so I was using it.

I tried an alternative as well to use toobjectid in mongo aggregation pipeline to convert array of string object ids to mongo object ids , it seems to work but if the array is big , it takes a lot of time so I am searching for javascript approach

    $match: {
      $expr: {
        $in: [
            $map: {
              input: {{ formatDataAsObject( }},
              in: {
                $toObjectId: "$$this",

Above is the mongo query which I tried but takes more than 20 sec to execute if array is long

Ah I see, I believe you shouldn't have to import any external libraries to get this to work, for example, if you want to pass an ID to mongo, you can run something like the following:\

Does this work for your use case here?\

Hey thank you for the reply but this is for converting a single string to object id , in my use case I need to convert an array of strings to object id, so thats why query is taking a long time to execute, any help in this case would be appreciated

Hey @Balachandra!

A coworker of mine pointed me to this thread with a possible solution here. Does this look like what you're trying to do?