How can I save a stored javascript into mongodb from node.js

后端 未结 1 1619
太阳男子
太阳男子 2020-12-30 13:34

The following piece of code:

var mongo = require(\'mongodb\');

var db = new mongo.Db(\'test\', new mongo.Server(\'127.0.0.1\', 27017, {}));

var callback          


        
相关标签:
1条回答
  • 2020-12-30 14:08

    After reading the documentation about the driver data types, I realized that instead of passing the string with the code, I needed to pass a mongo.Code object:

    {
      "_id" : "myFunction",
      "value" : new mongo.Code("function myFunction() { return 123; }")
    }
    
    0 讨论(0)
提交回复
热议问题