How to replace the deprecated ScriptDb with Mongodb using URL Fetch service?

三世轮回 提交于 2019-11-30 16:20:16

问题


Due to the recent ScriptDb deprecation I need to replace it. I chose MongoDb(as I need noSQL db). Google does not provide any guides on how to connect mongo. It's just said that one should use mongolab and URL Fetch service.

I created a data base on mongolab. They gave me the following ways of connecting to it:

To connect using the shell:
   mongo ds045679.mongolab.com:45679/prjacc -u <dbuser> -p <dbpassword>
To connect using a driver via the standard URI (what's this?):
   mongodb://<dbuser>:<dbpassword>@ds045679.mongolab.com:45679/prjacc

But there's no driver for google script so I can't figure out how to replace my old code:

var db = ScriptDb.getMyDb();
// work with db...

with access to mongo using URL Fetch Service.

Any help is appreciated!


回答1:


It seems that I've found a solution. MongoDB also provides the third way of accessing the DB, though they strongly recommend to use 2 ways described in my question. This is to use their REST API:

So it seems we should pass this url https://api.mongolab.com/api/1/databases?apiKey=<your-api-key> to the UrlFetchApp.fetch() function.

Please correct me if I'm not right. Any additions and notes are appreciated.



来源:https://stackoverflow.com/questions/24033530/how-to-replace-the-deprecated-scriptdb-with-mongodb-using-url-fetch-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!