开发者

Is there a better way to use javascript to import of data from an external URL into mongo db

开发者 https://www.devze.com 2023-03-30 20:28 出处:网络
The best I can come up with is to use the mongo shell \"run\" comm开发者_C百科and to: execute curl write to pull $someUrl to fs/tmp/myfile.ext

The best I can come up with is to use the mongo shell "run" comm开发者_C百科and to:

  1. execute curl write to pull $someUrl to fs/tmp/myfile.ext
  2. execute mongoimport to load fs/tmp/myfile.ext

I don't know the file system structure at compile time, so I am hoping the Gurus may know of a more direct way of loading data from a remote URL.


You can do this quite easily with any of the languages or drivers.

So if you use PHP + cURL + MongoDB, you can basically store the response right into MongoDB with all of the features of cURL.

The same should be true for most dynamic languages Python, Ruby, etc. If you use Node.js, the process should be quite similar. I only suggest the dynamic language for ease of scripting, but pretty much any of the supported drivers should allow you to do this.

Frankly storing it in a file is probably unnecessary.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号