[SERVER-4450] allow automatic run of code from the stored library when loaded into context Created: 07/Dec/11  Updated: 08/Jan/24  Resolved: 01/Feb/16

Status: Closed
Project: Core Server
Component/s: JavaScript
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Major - P3
Reporter: Antoine Girbal Assignee: Mira Carey
Resolution: Done Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Sprint: Platforms F (01/29/16)
Participants:

 Description   

There has been several tickets about how to upload a working library to the server, like:
http://stackoverflow.com/questions/8418651/techniques-for-storing-libraries-in-mongodbs-system-js

Turns out this is automatically done in v8: it will always run code as it is loaded.
If you save:
db.system.js.save({ _id: "mylib", value: "myprint = function()

{ print('installed'); return 'installed';" }

Then you can use myprint() freely in your code

With spidermonkey it is not done.
We should standardize and make it so that:

  • by default code does not get run
  • if there is a flag set on the object "run: true" then run it as it is installed on context.


 Comments   
Comment by Mira Carey [ 01/Feb/16 ]

We've lived without this feature for a long time, and I don't believe we want arbitrary evaluation in loadServerScripts in any case.

Comment by Reuben Garrett [ 07/Dec/11 ]

Thanks, Antoine, for responding. In case it's helpful, below are two discussions relevant to this request:
https://jira.mongodb.org/browse/SERVER-770
http://groups.google.com/group/mongodb-user/browse_thread/thread/27aaf8261b5fff46

Generated at Thu Feb 08 03:06:01 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.