Javascript MongoDB 有原生的 REST 接口吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7386740/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 02:03:57  来源:igfitidea点击:

Does MongoDB have a native REST interface?

javascriptapirestmongodb

提问by Mayank Jain

I am currently evaluating Mongo and CouchDB for storing data points (analytics).

我目前正在评估 Mongo 和 CouchDB 用于存储数据点(分析)。

During my earlier interaction with CouchDB, I loved its JSONP based interface. I could perform all CRUD operations from purely JavaScript. Just run CouchDB and write some JavaScript - no server side component needed.

在我早期与 CouchDB 的交互中,我喜欢它基于 JSONP 的界面。我可以从纯 JavaScript 执行所有 CRUD 操作。只需运行 CouchDB 并编写一些 JavaScript - 不需要服务器端组件。

When comparing this to Mongo, is there any REST interface available? Is it possible to do CRUD purely from javascript in Mongo?

将其与 Mongo 进行比较时,是否有可用的 REST 接口?是否可以完全从 Mongo 中的 javascript 进行 CRUD?

Thanks!

谢谢!

回答by Tomasz Nurkiewicz

There is no full-blown REST interface to MongoDB, mainly because the server uses native binary protocol for efficiency. You can find few REST wrappers in official documentation:

MongoDB 没有成熟的 REST 接口,主要是因为服务器使用本机二进制协议来提高效率。您可以在官方文档中找到一些 REST 包装器:

  • RESTHeart(Java 8) is a the data REST API server part of the MongoDB ecosystem. RESTHeart uses a standard representation format based on HAL with full native mongodb data support via the strict mode representation of BSON. It provides API for CRUD and data model operations, built-in authentication and authorization and it supports CORS. It is easy to setup and a docker container is available. RESTHeart is also fast and lightweight (~7 Mb footprint and ~200 Mb RAM peek usage).

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

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

  • Simple REST InterfaceThe 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.

  • RESTHeart(Java 8) 是 MongoDB 生态系统的数据 REST API 服务器部分。RESTHeart 使用基于 HAL 的标准表示格式,通过 BSON 的严格模式表示具有完整的原生 mongodb 数据支持。它提供了用于 CRUD 和数据模型操作的 API,内置身份验证和授权,并支持 CORS。它很容易设置,并且有一个 docker 容器可用。RESTHeart 也快速且轻量级(约 7 Mb 的占用空间和约 200 Mb 的 RAM 使用量)。

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

  • MongoDB Rest(Node.js) 是MongoDBalphaREST 接口,它使用 MongoDB Node Native 驱动程序。

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

回答by Matt Zukowski

Another option (shameless plug) is DrowsyDromedary.

另一种选择(无耻的插头)是DrowsyDromedary

We developed Drowsy out of frustration with the other REST options for Mongo. Namely, we found that:

出于对 Mongo 的其他 REST 选项的失望,我们开发了 Drowsy。也就是说,我们发现:

Sleepy Mongooseis not really RESTful. It's a hacky HTTP interface that does not follow REST conventions; it doesn't use the standard REST HTTP methods, it doesn't use URLs to properly identify resources... We also found the options for limiting the maximum number of results (which is limited by default) rather confusing.

Sleepy Mongoose并不是真正的 RESTful。这是一个不遵循 REST 约定的 hacky HTTP 接口;它不使用标准的 REST HTTP 方法,它不使用 URL 来正确识别资源......我们还发现限制最大结果数(默认情况下是有限的)的选项相当混乱。

mongodb-restoffers a proper REST interface, but we found it to be a pain in the ass to run. It would die regularly, and drove our sysadmin insane (who admittedly has little experience running node.js services).

mongodb-rest提供了一个合适的 REST 接口,但我们发现它运行起来很麻烦。它会定期死亡,并让我们的系统管理员发疯(不可否认,他几乎没有运行 node.js 服务的经验)。

The built-in REST interfacewould have been great, but it being read-only means it's mostly useless for our needs.

内置REST接口将是巨大的,但它被只读意味着它是对我们的需求大多是无用的。

DrowsyDromedary, was developed to address many of the above issues:

DrowsyDromedary旨在解决上述许多问题:

  1. It provides a conventional REST interface, with support for the standard HTTP verbs (GET, POST, PUT, DELETE, PATCH).
  2. It's fairly easy to install and deploy (clone from github, install bundler, run bundle, and then rackup, and you're running). It can also be easily deployed under Apache or nginx.
  1. 它提供了一个传统的 REST 接口,支持标准的 HTTP 动词(GET、POST、PUT、DELETE、PATCH)。
  2. 安装和部署相当容易(从 gi​​thub 克隆,安装 bundler,运行bundle,然后运行,然后rackup运行)。它也可以轻松部署在 Apache 或 nginx 下。

回答by Harry

Edit

编辑

Python Eveis a fantastic solution for this. I have found it very easy to use and highly configurable.

Python Eve是一个很好的解决方案。我发现它非常易于使用且高度可配置。

Eve is an open source Python REST API framework designed for human beings. It allows to effortlessly build and deploy highly customizable, fully featured RESTful Web Services.

Eve is powered by Flask, Redis, Cerberus, Events and offers support for both MongoDB and SQL backends [*].

The codebase is thoroughly tested under Python 2.6, 2.7, 3.3, 3.4 and PyPy.

Eve 是一个为人类设计的开源 Python REST API 框架。它允许毫不费力地构建和部署高度可定制、功能齐全的 RESTful Web 服务。

Eve 由 Flask、Redis、Cerberus、Events 提供支持,并提供对 MongoDB 和 SQL 后端的支持 [*]。

代码库在 Python 2.6、2.7、3.3、3.4 和 PyPy 下经过全面测试。

It is as simple to get started as:

入门非常简单,如下所示:

from eve import Eve

app = Eve()
app.run()

and to use as

并用作

$ curl -i http://example.com/people
  HTTP/1.1 200 OK

REST endpoint schemas are easily defined in a settings file.

REST 端点架构很容易在设置文件中定义。

Original

原来的

I haven't used it yet, but RESTHeartlooks like an answer to this.

我还没有使用它,但RESTHeart看起来像是对此的答案。

From the documentation it looks easy to set up and use.

从文档来看,它看起来很容易设置和使用。

回答by Mayank Jain

mongodb-rest's fork by ActibeUnits (github repo) is one of the fastest and most feature rich rest interface to mongodb that I've seen.

ActibeUnits ( github repo) 的mongodb-rest 分支是我见过的最快、功能最丰富的 mongodb rest 接口之一。

I would highly recommend it.

我会极力推荐它。

回答by Thilo

Not really. The mongod process includes a simple read-only REST interfacefor convenience. For full REST capabilities you need to use an external tool such as Sleepy.Mongoose.

并不真地。为方便起见,mongod 进程包含一个简单的只读 REST 接口。要获得完整的 REST 功能,您需要使用外部工具,例如 Sleepy.Mongoose。

回答by Andrea Di Cesare

RESTHeartis a the new data REST API server part of the MongoDB ecosystem.

RESTHeart是 MongoDB 生态系统中新的数据 REST API 服务器部分。

It provides APIfor CRUD and data model operations, built-in authentication and authorization and supports CORS.

为CRUD和数据模型操作提供API,内置认证和授权,支持CORS

It uses a standard representation formatbased on HAL+jsonwith full support of the native mongodb data format via the strict mode representation of BSON.

它使用基于HAL+json的标准表示格式,通过 BSON 的严格模式表示完全支持原生 mongodb 数据格式。

It is easy to setupand a docker containeris available.

它很容易设置,并且有一个docker 容器可用。

RESTHeart is fast (see performance test result) and lightweight (~7 Mb footprint and ~200 Mb RAM peek usage).

RESTHeart 速度快(参见性能测试结果)和轻量级(~7 Mb 占用空间和~200 Mb RAM 偷看使用量)。

回答by Ashley Davis

No. But mongodb-restis moving forward now.

不,但是mongodb-rest现在正在向前发展。

https://github.com/codecapers/mongodb-rest

https://github.com/codecapers/mongodb-rest