Mongodb客户端javascript api [英] Mongodb client side javascript api

查看:120
本文介绍了Mongodb客户端javascript api的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从客户端直接使用mongodb,在我的模型中使用javascript。我想这是可能的,因为在mongo网站上有一个javascript实时控制台演示。



存在一种方法使用相同的api在一个普通的javascript应用程序,

解决方案

查看像网站使用类似REST的AJAX接口,但我确定它不直接访问任何MongoDB实例或甚至间接通过一些桥梁。



在应用之前考虑两次模式:你将如何强制安全?你知道AJAX的限制吗?如果您真的知道您在做什么,官方的文档指向一些有用的资源:



  • Sleepy Mongoose (Python)是一个功能齐全的MongoDB REST接口,可作为单独的项目使用。

    li>
  • MongoDB Rest (Node.js)是一个 alpha 到MongoDB的REST接口,它使用MongoDB Node Native驱动程序。


  • 简单REST接口为方便起见,mongod进程包括一个简单的只读REST接口。对于完整的REST功能,我们建议您使用外部工具,例如 Sleepy .Mongoose



拥有REST桥接并管理< a href =http://en.wikipedia.org/wiki/Same_origin_policy>同源策略,您可以使用AJAX调用和JavaScript直接访问MongoDB。


I would like to use mongodb directly from the client-side, using javascript inside my models. I suppose this is possible since on the mongo website there is a javascript realtime console for demo.

Does exist a way to use the same api in a normal javascript application without having to write client-server glue code?

Thanks

解决方案

Looks like the site uses REST-like AJAX interface, but I am certain that it does not access any MongoDB instance directly or even indirectly via some bridge.

Thinks twice before applying this pattern: how will you enforce security? Are you aware of AJAX limitations? If you really know what you are doing, the official documentation points to few useful resources:

  • Sleepy Mongoose (Python) is a full featured REST interface for MongoDB which is available as a separate project.

  • MongoDB Rest (Node.js) is an alpha REST interface to MongoDB, which uses the MongoDB Node Native driver.

  • Simple REST Interface The mongod process includes a simple read-only REST interface for convenience. For full REST capabilities we recommend using an external tool such as Sleepy.Mongoose.

Having a REST bridge and managing the same origin policy you can easily access MongoDB directly using AJAX calls and JavaScript.

这篇关于Mongodb客户端javascript api的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆